Блог пользователя Pratik_

Автор Pratik_, история, 3 года назад, По-английски

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

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

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.

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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.