Hazemshehaway's blog

By Hazemshehaway, history, 4 weeks ago, In English

I know why it is time limit error, but why both two codes failed in two different test cases I only changed cin/cout to printf/scanf ؟؟؟

code 1 code2

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

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

You can check this link to understand the difference also add these two lines to your template if you want to use cin/cout as they make them run faster

ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);

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

    No I know they are faster but why the faster one get TLE in 68 test case and the slower one get TLE in 101?????????

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

scanf, printf is faster than cin, cout

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

    No I know they are faster but why the faster one get TLE in 68 test case and the slower one get TLE in 101?????????

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

i don't think this is about i/o since there is only a single integer output. When I ran code 1 (the one with cout) in gnu c++17 it gave tle on tc 67, so ig its about some optimization in gnu c++14

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

    I cannot understand the problem yet I only changed the input and also on gnu17 this give me compilation error?