M.Ibrahim_'s blog

By M.Ibrahim_, history, 4 years ago, In English

You can find the solution of Problem A Div1 as soon as you search about it.

You can see this link

you've to add just one condition in ”else” and get problem accepted

if(i == pp.first || i == pp.second || j == pp.first || j == pp.second) continue;

Accepted Solution 109890606

Therefore, this is unfair to some of the contestants.

Is it possible to find a solution ???

ch_egor

MikeMirzayanov

  • Vote: I like it
  • -25
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Thank You for the trivial $$$\mathcal O(n^2)$$$ solution.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Time complexity of map insert and search is O($$$Log N$$$). So this solution is O($$$N^2 Log N$$$) not O($$$N^2$$$).

    But this solution get accepted check this 109890606

    • »
      »
      »
      4 years ago, # ^ |
      Rev. 2   Vote: I like it +5 Vote: I do not like it

      Well, It's actually $$$min(n^2, 5 \cdot 10^6)$$$. I hope you just got lucky without proving your solution. And yeah, It's $$$\mathcal O(n^2logn)$$$ I thought they used unordered_map.

»
4 years ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

The algorithm mentioned in the article can not handle the case where N >= 5000.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Oh, you mean that the code can pass the system test with an additional line of code.

    Anyway, the constraints ensure that there is an algorithm of O(5,000,000).

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    You can check accepted solution.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Oh, It's a terrible thing.
But I don't think it matters because people rarely know.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +25 Vote: I do not like it

    i check every contest problem at geeks for geeks before thinking on my own