|
|
back to boardhelp me please! Posted by 〇$十ვ尸 26 Jan 2016 21:58 i have WA on test #3 my code here: #include <iostream> using namespace std; int main() { int n, s = 0; cin >> n;
string *arr = new string[n]; string a; getline(cin, a); for(int i = 0; i < n; i++) { getline(cin, a); for(int j = 0; j < i; j++) { if(a == arr[j]) { s++; break; } else arr[i] = a; } }
cout << s << endl;
return 0; } Edited by author 26.01.2016 21:58 Re: help me please! Try test: 2 a a - Your answer is 1, expected is 0 Also your solution has O(n*n) complexity. I expect (or at least hope) you will have TLE. Edited by author 27.01.2016 18:07 Re: help me please! Can't edit prev message. > Your answer is 1, expected is 0 Should be: Your answer is 0, expected is 1 |
|
|