Page 4 of 4
Re: 10082 - WERTYU
Posted: Mon Sep 29, 2008 5:26 pm
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);
}
Re: 10082 - WERTYU
Posted: Wed Nov 19, 2008 6:35 pm
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);
}
Re: 10082 - WERTYU
Posted: Tue Jan 13, 2009 5:20 pm
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.
Re: 10082 - WERTYU
Posted: Tue May 11, 2010 11:28 pm
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.
Re: 10082 - WERTYU
Posted: Thu May 13, 2010 11:06 am
by sohel
May be a bug.
WERTYU
Posted: Wed Sep 01, 2010 4:51 pm
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();
}
}
}
Re: WERTYU
Posted: Thu Sep 02, 2010 5:25 pm
by niloo
well, I post It once more..!! I got AC.
Re: 10082 - WERTYU
Posted: Sun Nov 14, 2010 6:34 am
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;
}
Re: 10082 - WERTYU
Posted: Mon Nov 29, 2010 11:12 pm
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.
10082 - WERTYU
Posted: Fri Aug 05, 2011 9:52 pm
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,

Re: 10082 - WERTYU
Posted: Tue Oct 23, 2012 1:14 pm
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
Re: 10082 - WERTYU
Posted: Fri Jan 11, 2013 1:09 pm
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
Re: 10082 - WERTYU
Posted: Mon Mar 02, 2015 6:29 pm
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;
}