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

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

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

http://mirror.codeforces.com/contest/761/submission/24331207

http://mirror.codeforces.com/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
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 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.

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

    That's brilliant! Can't believe I made such a stupid mistake, thanks a lot! :)

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

    However on the code defining inf as 10^9 and did not initialize temp either, not sure why did that AC. :/

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

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

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

    Still doesn't work. It's as Morass said, I did not initialize the value of temp. But thanks anyway!

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

bool trump[3];

Trump Supporter detected.