10761 - Broken Keyboard
Moderator: Board moderators
10761 - Broken Keyboard
Hi,
How about blank lines in the text? Shall I count them as a good line or not? For instance:
eN
E
n
;
END
finish
Is this output correct:
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 2 | abcdfghijklmopqrstuvwxyz |
+----------+----------------+-----------------------------+
or it should rather be:
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 1 | abcdfghijklmopqrstuvwxyz |
+----------+----------------+-----------------------------+
Wojciech
How about blank lines in the text? Shall I count them as a good line or not? For instance:
eN
E
n
;
END
finish
Is this output correct:
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 2 | abcdfghijklmopqrstuvwxyz |
+----------+----------------+-----------------------------+
or it should rather be:
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 1 | abcdfghijklmopqrstuvwxyz |
+----------+----------------+-----------------------------+
Wojciech
10761 - Broken keyboards
Hi,
How about blank lines in the text? Shall I count them as a good line or not? For instance:
eN
E
n
;
END
finish
Is this output correct:
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 2 | abcdfghijklmopqrstuvwxyz |
+----------+----------------+-----------------------------+
or it should rather be:
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 1 | abcdfghijklmopqrstuvwxyz |
+----------+----------------+-----------------------------+
Wojciech
How about blank lines in the text? Shall I count them as a good line or not? For instance:
eN
E
n
;
END
finish
Is this output correct:
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 2 | abcdfghijklmopqrstuvwxyz |
+----------+----------------+-----------------------------+
or it should rather be:
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 1 | abcdfghijklmopqrstuvwxyz |
+----------+----------------+-----------------------------+
Wojciech
-
- Guru
- Posts: 584
- Joined: Thu Jun 19, 2003 3:48 am
- Location: Sanok, Poland
- Contact:
IMHO the first output is correct. You can type a blank line with any set of broken letters. (You can also type any other line with only non-alphabetic characters.) My program giving this output is AC.
Anyhow, probably there is no such test case... (I assume Krzysztof also has AC with a program giving the opposite answer.)
Anyhow, probably there is no such test case... (I assume Krzysztof also has AC with a program giving the opposite answer.)
-
- Guru
- Posts: 584
- Joined: Thu Jun 19, 2003 3:48 am
- Location: Sanok, Poland
- Contact:
The only special case I can think of is when there are no printable lines, i.e.
when the output should be
Also check for stupid typos in the output and check whether you are formatting the result properly when there are more than 9 keyboards/printable lines.
Code: Select all
abcde
aaaaa
bbbbb
C C C C C
ddddd
END
finish
Code: Select all
+----------+----------------+-----------------------------+
| Keyboard | # of printable | Additionally, the following |
| | lines | letter keys can be broken |
+----------+----------------+-----------------------------+
| 1 | 0 | fghijklmnopqrstuvwxyz |
+----------+----------------+-----------------------------+
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
Be sure to print spaces (ASCII 0x20) in the output. The HTML of the problem statement contains high ASCII (0xA0) that look like spaces, but will lead to WA if you copy it into your output statements. I had this problem during the contest and couldn't figure out why I had WA until I looked at my source code with a hex-editor.
Shahriar Manzoor who edits most of the problem statements nowadays, seems to use some kind of MickyMouse editor to build the HTML-pages. Apart from looking terrible in any non-IE browser, the source text of the pages contain all kinds of non-standard crap characters which can lead to unexpected errors. Although UVA runs on Linux and pretends to be W3C compliant on their main page, Microsoft is creaping in steadily...
Shahriar Manzoor who edits most of the problem statements nowadays, seems to use some kind of MickyMouse editor to build the HTML-pages. Apart from looking terrible in any non-IE browser, the source text of the pages contain all kinds of non-standard crap characters which can lead to unexpected errors. Although UVA runs on Linux and pretends to be W3C compliant on their main page, Microsoft is creaping in steadily...
hear is my code... can u tell me what is wrong hear ??
[pascal][/pascal]
[pascal]
Code: Select all
var wc,t,s,break:string;
keyboard,printable,a:longint;
dodatkowe:array['A'..'Z'] of boolean;
finito,koniec,niemoze:boolean;
x:char;
procedure zeroo;
begin
wc:='';
t:='';
s:='';
break:='';
for x:='A' to 'Z' do dodatkowe[x]:=false;
printable:=0;
finito:=false;
niemoze:=false;
end;
function nalezy(x:char):boolean;
begin
if ((ord(x)>96) and (ord(x)<123)) or
((ord(x)>64) and (ord(x)<91))
then nalezy:=true else nalezy:=false;
end;
procedure read_data;
begin
koniec:=false;
readln(s);
if s='finish' then koniec:=true;
if koniec=false then
begin
for a:=1 to length(s) do
break:=break+upcase(s[a]);
for a:=1 to length(break) do
dodatkowe[break[a]]:=true;
repeat
readln(t);
s:='';
for a:=1 to length(t) do
if nalezy(t[a]) then s:=s+upcase(t[a]);
niemoze:=false;
if length(s)>0 then
begin
for a:=1 to length(break) do
if pos(break[a],s)>0 then niemoze:=true;
end;
if (niemoze=false) and (length(t)>0) then
begin
inc(printable);
for a:=1 to length(s) do
dodatkowe[s[a]]:=true;
end;
if length(s)>2 then
if (s[1]='E') and (s[2]='N') and (s[3]='D') then finito:=true;
until finito;
write('|');
inc(keyboard);
write(keyboard:6);
write('|':5);
write(printable:9);
write('|':8);
for x:='A' to 'Z' do
if dodatkowe[x]=false then wc:=wc+chr(ord(x)+32);
write(' ',wc);
writeln('|':26-length(wc)+3)
end;
end;
begin
writeln('+----------+----------------+-----------------------------+');
writeln('| Keyboard | # of printable | Additionally, the following |');
writeln('| | lines | letter keys can be broken |');
writeln('+----------+----------------+-----------------------------+');
repeat
zeroo;
read_data;
if koniec=false then
writeln('+----------+----------------+-----------------------------+');
until koniec;
writeln;
end.
Last edited by brianfry713 on Tue Dec 02, 2014 11:42 pm, edited 1 time in total.
Reason: Added code blocks
Reason: Added code blocks
Remember Never Give Up
Regrads
Miras
Regrads
Miras
10761 - broken keyborad
i have passed any samples,why i always got WA?
[cpp][/cpp]
[cpp]
Code: Select all
#include <iostream>
using namespace std;
#include <cstdio>
#include <cstring>
int main()
{
bool key[26],key2[26];
bool f;
char brokenkey[26];
char line[100];
int i;
int len;
int c=1;
int num;
int temp;
cout<<"+----------+----------------+-----------------------------+"<<endl;
cout<<"| Keyboard | # of printable | Additionally, the following |"<<endl;
cout<<"| | lines | letter keys can be broken |"<<endl;
cout<<"+----------+----------------+-----------------------------+"<<endl;
while(cin.getline(brokenkey,26))
{
if(!strcmp(brokenkey,"finish"))
break;
for(i=0;i<26;i++)
{
key[i]=true;
key2[i]=true;
}
num=0;
f=false;
temp=0;
len=strlen(brokenkey);
for(i=0;i<len;i++)
{
if(brokenkey[i]>='A'&&brokenkey[i]<='Z')
brokenkey[i]=char(int(brokenkey[i])+32);
}
for(i=0;i<len;i++)
{
key[brokenkey[i]-97]=false;
key2[brokenkey[i]-97]=false;
}
while(cin.getline(line,1000))
{
if(!strcmp(line,"END"))
f=true;
len=strlen(line);
for(i=0;i<len;i++)
{
if(line[i]>='A'&&line[i]<='Z')
line[i]=char(int(line[i])+32);
}
for(i=0;i<len;i++)
{
if(line[i]>='a'&&line[i]<='z')
if(key[int(line[i])-97]==false)
break;
}
if(i==len)
{
num++;
for(i=0;i<len;i++)
{
key2[int(line[i])-97]=false;
}
}
if(f)
break;
}
printf("|%6d |%9d | ",c++,num);
for(i=0;i<26;i++)
{
if(key2[i])
{cout<<char(i+97);
temp++;}
}
for(i=0;i<28-temp;i++)
cout<<" ";
cout<<"|"<<endl;
cout<<"+----------+----------------+-----------------------------+"<<endl;
}
return 0;
}
Last edited by brianfry713 on Tue Dec 02, 2014 11:43 pm, edited 1 time in total.
Reason: Added code blocks
Reason: Added code blocks
I checked with hex editor that
printf("|%6hd |%9hd | %-28s|\n",klaw,nl,uz); gives correct output, that means the only white characters used are spaces and newline - at least on my computer. Do You think that on judge system might be different? Other words: Is it possible that on judge system such command output could use other white characters?
Wojciech
printf("|%6hd |%9hd | %-28s|\n",klaw,nl,uz); gives correct output, that means the only white characters used are spaces and newline - at least on my computer. Do You think that on judge system might be different? Other words: Is it possible that on judge system such command output could use other white characters?
Wojciech
-
- New poster
- Posts: 12
- Joined: Tue Sep 21, 2004 10:08 pm