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 1563. Bayan

Show all messages Hide all messages

whats wrong?? Igor 25 Oct 2007 02:41
I dont know/My programm out 3 in the 1 test/And it is wrong.But if wright
cout << "3";
it is right/
???????
Re: whats wrong?? timur 25 Oct 2007 02:43
Check if you are reading the entire line. Also check if you clean the buffer (cin.ignore()) before reading.
Re: whats wrong?? Igor 25 Oct 2007 02:47
i wright
.....
while ( cin.get(c) && (int)c!=10 )
.......
and it is wrong??
Re: whats wrong?? timur 25 Oct 2007 02:52
If you checking the new line character I think '\n' is safe.
Re: whats wrong?? Igor 25 Oct 2007 02:59
in the end of file there are enter character or not?
Re: whats wrong?? timur 25 Oct 2007 03:04
I don't know. I suggest you to use

string s;
getline(cin,s);

to get an entire line in s. Before all this, you need cin.ignore(); to clean the buffer.
Re: whats wrong?? Igor 25 Oct 2007 03:19
i've got WA 1/  It does not help.
Re: whats wrong?? Igor 25 Oct 2007 03:27
i use
cin >> n;
...
cin.ignore();
while ( i<=n && getline (cin,s) )
    {
        int t=0;
        find (i);
                ++i;
    }
...
cout << sum ;
Re: whats wrong?? timur 25 Oct 2007 03:58
What is "find(i)"? May be you don't need getline inside while(*). I don't know if it is allowed, but you can compare yours with my code:

#include <iostream>
#include <string>
#include <set>
using namespace std;

int main()
{
int n;
cin >> n;
set<string> ss;
string s;
int k=0;
cin.ignore();
for (int i=0;i<n;i++) { getline(cin,s); if(ss.find(s)!=ss.end()) k++; else ss.insert(s); }
cout << k;
return 0;
}


Edited by author 25.10.2007 04:00

Edited by author 25.10.2007 04:00
Re: whats wrong?? Igor 25 Oct 2007 04:03
i am doing almost the same thing.