10082 - WERTYU

All about problems in Volume 100. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

rajulanand
New poster
Posts: 1
Joined: Mon Sep 29, 2008 4:49 pm

Re: 10082 - WERTYU

Post by rajulanand »

I'm getting WA. On my pc i've tested with several inputs...don't know why it's showing wrong answer. I have a hint that may be it's problem with newline. Here's my code..plz give some valuable input.

Code: Select all

#include<cstdio>
#include<iostream>
#include<vector>

using namespace std;


vector<int> map;
void add(int ch)
{
     map.push_back(ch);
 }

int main()
{
    map.reserve(100);
    //start from upper corner
    add('`');
    for(int i=0; i < 9 ; i++)
    add(i+1);  
    add(0);
    add('-');
    add('=');
    //second row
    add('Q'),add('W'),add('E'),add('R'),add('T'),add('Y'),add('U'),add('I'),add('O'),add('P'),add('['),add(']'),add('\\');
    //third row
    add('A'),add('S'),add('D'),add('F'),add('G'),add('H'),add('J'),add('K'),add('L'),add(';'),add('\'');
    //last row
    add('Z'),add('X'),add('C'),add('V'),add('B'),add('N'),add('M'),add(','),add('.'),add('/');   
    
    
    vector<int>::iterator idx;
    bool f= false;
    string s;
    while(getline(cin,s))
    {
             if(f)
             cout<<"\n";
             
    
             
              f=true;
              for(int i=0; i < s.length() ;i++)
              {
                  if(s[i] != 32 ) 
                 {
                      idx = find(map.begin(),map.end(),s[i]);
                      
                      if(idx != map.end())
                      {
                             idx--;
                            cout <<static_cast<char>(*idx);
                       }
                   }
                   else
                   cout<<" ";  
                      
              }
             
    }
    return (0);
}
poixp
New poster
Posts: 20
Joined: Mon Apr 07, 2008 11:05 am

Re: 10082 - WERTYU

Post by poixp »

Simple hints:
1. Don't use std::vector or something else for that problem. Just use static array.
2. Array must be filled such that you could simply write: cout << encode_table[ input_char ];
rajulanand wrote:I'm getting WA. On my pc i've tested with several inputs...don't know why it's showing wrong answer. I have a hint that may be it's problem with newline. Here's my code..plz give some valuable input.

#include<cstdio>
#include<iostream>
#include<vector>

using namespace std;


vector<int> map;
void add(int ch)
{
map.push_back(ch);
}

int main()
{
map.reserve(100);
//start from upper corner
add('`');
for(int i=0; i < 9 ; i++)
add(i+1);
add(0);
add('-');
add('=');
//second row
add('Q'),add('W'),add('E'),add('R'),add('T'),add('Y'),add('U'),add('I'),add('O'),add('P'),add('['),add(']'),add('\\');
//third row
add('A'),add('S'),add('D'),add('F'),add('G'),add('H'),add('J'),add('K'),add('L'),add(';'),add('\'');
//last row
add('Z'),add('X'),add('C'),add('V'),add('B'),add('N'),add('M'),add(','),add('.'),add('/');


vector<int>::iterator idx;
bool f= false;
string s;
while(getline(cin,s))
{
if(f)
cout<<"\n";



f=true;
for(int i=0; i < s.length() ;i++)
{
if(s != 32 )
{
idx = find(map.begin(),map.end(),s);

if(idx != map.end())
{
idx--;
cout <<static_cast<char>(*idx);
}
}
else
cout<<" ";

}

}
return (0);
}
JohnTortugo
New poster
Posts: 18
Joined: Sun Jul 20, 2008 7:05 pm

Re: 10082 - WERTYU

Post by JohnTortugo »

I was using texto = gets(), with texto being char[10000] and was getting wrong answer... after I switch it for c = getchar(), i got AC.
amishera
New poster
Posts: 38
Joined: Sat Dec 27, 2008 10:42 pm

Re: 10082 - WERTYU

Post by amishera »

What does this mean?

Code: Select all

7961513  	10082  	WERTYU  	Accepted  	C++  	0.008  	2010-05-11 21:30:27
7961460 	10082 	WERTYU 		C++ 	0.000 	2010-05-11 20:54:31
7961442 	10082 	WERTYU 		C++ 	0.000 	2010-05-11 20:46:36
For the first 2 submissions there are no verdicts. And the mail I got has this:

Your submission with number 7961460 for the problem 10082 - WERTYU has failed with verdict .
Your submission with number 7961442 for the problem 10082 - WERTYU has failed with verdict .

It doesn't say WA, RTE, output limit exceeded, nothing. I had to make the variables global and then increase the array size to get it accepted.
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: 10082 - WERTYU

Post by sohel »

May be a bug.
niloo
New poster
Posts: 2
Joined: Wed Sep 01, 2010 4:40 pm

WERTYU

Post by niloo »

This simple problem is driving me mad .I have no idea what's wrong with that.!!
this is my code :
any ideas???
import java.util.Scanner;

class Main3 {
public static void main(String[] args) {
String prosseLine;
char prossChar;
char[] sequence = { '`', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '-', '=', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O',
'P', '[', ']', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L',
';', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/' };
Scanner scanner = new Scanner(System.in);

while (scanner.hasNext()) {
prosseLine = scanner.nextLine();
for (int i = 0; i < prosseLine.length(); i++) {
prossChar = prosseLine.charAt(i);
if (prossChar == 'A') {
System.out.print('A');
} else if (prossChar == 'Q') {
System.out.print('Q');
} else if (prossChar == 'Z') {
System.out.print('Z');
} else if (prossChar == '`') {
System.out.print('`');
} else if (prossChar == ' ') {
System.out.print(' ');
} else if (prossChar == 92) {
System.out.print(']');
} else if (prossChar == 39) {
System.out.print(';');
} else {
for (int j = 1; j < sequence.length; j++) {
if (prossChar == sequence[j]
&& (prossChar != 'A' || prossChar != 'Q' || prossChar != 'Z')) {
System.out.print(sequence[j - 1]);
continue;
}
}
}
}
System.out.println();
}

}
}
niloo
New poster
Posts: 2
Joined: Wed Sep 01, 2010 4:40 pm

Re: WERTYU

Post by niloo »

well, I post It once more..!! I got AC.
shababhsiddique
New poster
Posts: 2
Joined: Sun Nov 14, 2010 6:16 am

Re: 10082 - WERTYU

Post by shababhsiddique »

What causes WA?


#include<cmath>
#include<stdio.h>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
#include<algorithm>

using namespace std;

/*
#ifndef __GNUC__
typedef __unsigned long64 i64
#define I64d "%I64d"
#else
typedef long long i64
#define I64 "%lld"
#endif
*/

#define li(v) v.begin(),v.end()
#define sz(v) (unsigned long)v.size()
//#define inf(1e8+1)
#define testcase(tc) for(unsigned long kase=1;kase<=tc;++kase)
#define fo(i,start,stop) for(unsigned long i=start;i<stop;++i)
#define rfo(i,j,n) for(unsigned long i=n-1;i>=j;--i)
#define sfo(i,startindex,string) for(unsigned long i=startindex;i<(unsigned long)string.size();++i)
#define rsfo(i,startindex,string) for(unsigned long i=(unsigned long)string.size()-1;i>=startindex;--i)
#define Fo rfo
#define Foo rsfo
//#define pi (2*acos(0))
//#define eps 1e-9


map <char,char> swp;

int main()
{
freopen("input.txt","r",stdin);
string mstk="1234567890-=WERTYUIOP[]\\SDFGHJKL;\'XCVBNM,./";
string original="`1234567890-QWERTYUIOP[]ASDFGHJKL;ZXCVBNM,.";
//string mask="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZZXCVBNM,./";
//cout<<mstk<<endl<<original;

for(int i=0;i<sz(mstk);++i)
swp[mstk]=original;

string input="";
char output[999999];
sprintf(output,"");
while(getline(cin,input))
{
if(strlen(output)!=0)
sprintf(output,"%s\n",output);
fo(i,0,sz(input))
{
if(input!=' ')
sprintf(output,"%s%c",output,swp[input]);
else
sprintf(output,"%s ",output);
//printf("%c",swp[input]);
}

//printf("\n");//cout<<endl;
}
printf("%s",output);

return 0;
}
wrummler
New poster
Posts: 2
Joined: Mon Nov 29, 2010 10:35 pm

Re: 10082 - WERTYU

Post by wrummler »

Is anyone getting AC on UVa and PE on PC with this problem?

Code: Select all

Removed after taking it to heart that AC on one judge is good enough.
Seldaski
New poster
Posts: 2
Joined: Fri Aug 05, 2011 9:35 pm

10082 - WERTYU

Post by Seldaski »

SA,

I have got Wrong Answer in 10082 Problem.

I tested it and got right answers like that in Toolkit,
So i Hope any one can help me,

Here is my Code:
-------------------

import java.util.Scanner;

public class Main
{
public static void main(String[] args)
{
boolean bool;
String Output="";
char Chars[] = {'`','1','2','3','4','5','6','7','8','9','0','-','=','0','Q','W','E','R','T','Y','U','I','O','P','[',']','\\','A','S','D','F','G','H','J','K','L',';','\'','Z','X','C','V','B','N','M',',','.','/'};

Scanner in = new Scanner(System.in);
while(true)
{
String Input= in.nextLine();

for(int i=0;i<Input.length();i++)
{
bool = false;
if(Input.charAt(i) == 'A'||Input.charAt(i) == 'Z'||Input.charAt(i) == 'Q')
{

System.out.print(Input.charAt(i)); continue;}
for(int k=1;k<Chars.length;k++)
{
if(Input.charAt(i) == Chars[k])
{
System.out.print(Chars[k - 1]); bool=true; break;
}
}

if(!bool) System.out.print(Input.charAt(i));
}
System.out.println();
}
}
}


Thanks, :D
ajeet.singh82
New poster
Posts: 6
Joined: Wed Oct 10, 2012 7:31 am

Re: 10082 - WERTYU

Post by ajeet.singh82 »

Exactly two line of code -

istreambuf_iterator<char> iit (cin.rdbuf());
transform(iit, istreambuf_iterator<char>() , ostream_iterator<char>(cout), Decipher);


Believe me this will get AC
hansyulian
New poster
Posts: 3
Joined: Sat Dec 22, 2012 1:30 pm

Re: 10082 - WERTYU

Post by hansyulian »

I got WA before, but after i put that qwertyu[' '] = ' ', i got AC... so my mistake is just forget that space is space
praveenkumar13cs32
New poster
Posts: 4
Joined: Sat Dec 27, 2014 9:06 am

Re: 10082 - WERTYU

Post by praveenkumar13cs32 »

I challenge everybody find where my answer is wrong ? if u find plz help me. :(
I got five times WA. :(

Code: Select all

#include<cstdio>
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<char,char> k;
int main()
{
	int i;
    char key[]={'`','1','2','3','4','5','6','7','8','9','0','-','=','Q','W','E','R','T','Y','U','I','O','P','[',']','\\',
    'A','S','D','F','G','H','J','K','L',';','\'' , 'Z','X','C','V','B','N','M',',','.','/','\0'};
    for(i=1;key[i]!='\0';i++)
	{
		k[key[i]]=key[i-1];
	}
	key[' ']=' ';
    char s[10000];
    while(gets(s))
	{
		for(i=0;s[i]!='\0';i++)
			cout<<k[s[i]];
		cout<<endl;
	}
    return 0;
}
Post Reply

Return to “Volume 100 (10000-10099)”