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

Автор Tparsa, 10 лет назад, По-английски

Hello!

I have problem with this problem (:D !!) here is my submission

Thanks for your attention!

GOOD BYE !

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

»
10 лет назад, # |
Rev. 2   Проголосовать: нравится +13 Проголосовать: не нравится

Try changing from cin to scanf. It's a pretty big input, so maybe the issue lies there.

UPDATE: Indeed, changing to scanf gets it AC.

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

And as a side note, I saw in your code that you do (int)ceil( L[parV] / 2.0 ), when you could have simply done (L[parV] + 1) / 2. Without loss of generality, whenever you want to do ceil(a/b), it's more convenient to code (a+b-1)/b.

I know this has nothing to do with your original question, I just wanted to comment that.

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

cin.tie(0) might also help. I actually thought that it would be almost as fast as scanf but doesnt seem to be the case and it is not enough to get AC. However, endl is very slow and with cin.tie(0) and '\n' you can also get AC. With scanf and '\n' or printf it is even faster.

Is there some difference between ios_base::sync_with_stdio(0) and ios::sync_with_stdio(0)?