Pratik_'s blog

By Pratik_, history, 5 weeks ago, In English

I want to know why this error is occurs every time I try to run my code in codeforces. My code runs fluently in my PC but it's not running in cf editor. this is my submission : https://codeforces.com/contest/1433/submission/96685161

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

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

There is something wrong with the 1st line of main function. I faced similar problem with using that line on some other oj. I don't know what is the problem on that line under the hood, but you can use scanf/printf instead of that line. (Comment that line and submit again.)

»
5 weeks ago, # |
  Vote: I like it +11 Vote: I do not like it

ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); unties c-style io from cin. As a result you can't use both of them or you'll get weird behavior. In general you should always know what your template is doing. Otherwise if you just blindly paste you'll run into nasty errors like this.

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

I tried using scanf and then I got this https://codeforces.com/contest/1433/submission/96746653

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

    You're still using cin >> n inside of solution.

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

    You're still using cin in solution function as cin>>n;. You should use scanf only for the entire program. Actually, if you're going to use scanf, it's better to erase ios_base::sync_with_stdio(0) since it's useless anymore.

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

Thanks I got that