Скоро Codeforces Round 1133 (Div. 1, Div. 2)! Регистрация здесь. ×

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

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

I'm not sure if this is a bug, but would like to know why is this wrong.

http://codeforces.me/contest/761/submission/24331207

http://codeforces.me/contest/761/submission/24331035

Both of these codes are the same except one defines INF as 10e9, and the other as 1000000000. Yet one gets WA and the other didn't. Why is this? Thanks :)

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

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

Good day to you!

Well because "temp" might not be initialized when you use it:

if(i != j && j != k && i != k){
    temp = num[i] + let[j] + sym[k];
}
if(temp < INF){
    ans = min(ans, temp);
}

If the first condition is not "OK" and temp was not set yet, it could bring in an undefined value (such as -INF).

Setting it to INF shall get you AC.

But no clue whether the change of inf can influence it somehow (but as you can see, those INF's are different numbers, so perhaps something "in your code" [first inf is 10^10 second just 10^9] )

Good Luck & Have Nice Day.

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

10e9 is actually 1010. Try defining INF as 1e9.

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

bool trump[3];

Trump Supporter detected.