rahul_shrestha's blog

By rahul_shrestha, history, 19 months ago, In English

Problem Link: https://codeforces.net/contest/1809/problem/B

(Recent Edu Round Problem B)

Please watch these submissions for Problem B from my id:

https://codeforces.net/contest/1809/submission/198866759 : Says TLE on Test 1

https://codeforces.net/contest/1809/submission/198864293 : Says WA on Test 2

And now watch the same solution submitted by my friend after contest:

https://codeforces.net/contest/1809/submission/198867203 : SAYS AC !

Please explain the happening !

also all I tried to hack a cout<<sqrt(n-1) solution and I failed, so please find the bug.

  • Vote: I like it
  • +7
  • Vote: I do not like it

| Write comment?
»
19 months ago, # |
  Vote: I like it +10 Vote: I do not like it

The AC submission is using C++20, while yours is using C++17. Just floating point things.

  • »
    »
    19 months ago, # ^ |
    Rev. 2   Vote: I like it +9 Vote: I do not like it

    Actually! The AC submission is using C++ 17, not C++ 20 But yes that is a difference.

»
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by rahul_shrestha (previous revision, new revision, compare).

»
19 months ago, # |
Rev. 2   Vote: I like it +6 Vote: I do not like it
»
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

TLE Submission : in this submission, you have used int am() which expects an integer to be returned but since there is no return statement, the result is undefined behaviour (also cout does not have a return value hence resulting infinite loop. though im not sure)

  • »
    »
    19 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    yes, i also think the same hi happening, though in C++17, same code with no return value 198867203 is being accepted which was imteresting.