ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1094. E-screen

Strange problem! (for those who has wa 1)
Posted by Slam [Tartu U] 19 Mar 2008 00:58
1) For those who get WA 1 mb helps :
with
while (!cin.eof()) char c = cin.get();
i had WA 1
with
char t[10000];
cin.getline(t, 1000);
i had WA 9 !

2)
the problem says that the length of input is no more than 10000 characters

but this code
...
char t[10000];
cin.getline(t, 10000)
...
get WA9
this :
char t[20000];
cin.getline(t, 20000);
get AC

Strange, isn't it?
Re: Strange problem! (for those who has wa 1)
Posted by LuYizhou 12 Aug 2010 11:24
Yes,It's very strange!

-----------
char t[10001];
cin.getline(t,10000,'\n');
----------
I got WA9.

-----------
char t[10001];
cin.getline(t,10001,'\n');
----------
I got AC!
Re: Strange problem! (for those who has wa 1)
Posted by tiancaihb 12 Aug 2010 11:33
1. Maybe you didn't add a '\0' at the end of string when reading by chars.
2. For maxlen=10000, array must be at least as big as 10001!