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

help 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!
Posted by ToadMonster 27 Jan 2016 18:03
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!
Posted by ToadMonster 27 Jan 2016 18:39
Can't edit prev message.

> Your answer is 1, expected is 0

Should be:
Your answer is 0, expected is 1