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

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

Hello,

I have an error with my rust code https://codeforces.me/contest/231/submission/196189763.

I understand that I can't read the input but I don't understand the reason.

Can you help me? thanks

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

»
4 года назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +5 Проголосовать: не нравится

Your input implementation has a few bugs in it that could be causing the runtime error.

First of all you're assuming that the only whitespace characters in the input are space and \n, but on windows there's also \r(among others), which would cause your code to not break out of the loop and try to parse the \r and thus panick/runtime error on windows.

I'm not sure if that's what's causing the error or if it is another bug in your input struct but the input implementation is definitely the issue.

There's also the fact that your input template is not very performant(you clear the buffer String several times and perform several system calls to read the next line instead of reading all at once).

Here's a shorter and better rust template for input which uses macros(Please note that this template does NOT work with interactive problem):

https://ideone.com/4Z2CE3

and here's your answer rewritten using this template, which gets an AC verdict:

https://codeforces.me/contest/231/submission/196308655

Hope this helps you out!

EDIT: For some reason codeforces freaks out from the rust code so I will place them in ideone instead