Pratik_'s blog

By Pratik_, history, 4 years 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.me/contest/1433/submission/96685161

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

| Write comment?
»
4 years 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.

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

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

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

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

  • »
    »
    4 years 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.