Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Hi,

I dont know whom to send my query regarding this contest, so am just posting it here thinking i will get an explanation. I gave div2 contest today ( contest 284 ), and for problem C ( Crazy Town ), I made multiple submissions just because of a mistake that i think is because of the compiler. { if (val1>0 and val2<0) ans++; if (val2>0 and val1<0) ans++;

// if(val1>0 and val2<0) // ans++; // else if(val1<0 and val2>0) // ans++; } Here val1 and val2 are the values for two different points inserted in one single equation of line. Basically for checking if they lie on opposite or same side of line.

Can you please tell me if there is any difference between commented conditions and uncommented conditions, because if there is not, my solution was judged wrong because of this. You can also refer to my submissions for confirmation. I can see no value for val1 and val2 for which both if conditions would ever be true simultaneously. Also in my first submission you will find val1>=0 which should still work since val1 or val2 can never be zero according to problem constraints.

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

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

All of your wrong submissions have overflow issues.

a*x+b*y+c may be as large as 106 * 106 = 1012. So it is clear that solution with int's will already fail it.

And when you check that val1*val2<0 — you are multiplying 1012 and 1012, result may be something like 1024 — and it overflows even long long.