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

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

Why the same code, when submitted using GNU C++17 got accepted but when submitted using GNU C++17 (64) gave wrong answer ? This is the accepted one https://codeforces.net/contest/1365/submission/122433105 and this is the wrong one https://codeforces.net/contest/1365/submission/122431881 .

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

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

You have UB somewhere

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

more like compiler bug...

I tried your code in customtest with this test

1 2 2 #B G.

added some print before final two loops

cout<<s[1][0]<<endl;
cout<<vis[1][0]<<endl;
rep(i,0,n){
    rep(j,0,m){
        if((s[i][j]=='G' and not vis[i][j]) or (s[i][j]=='B' and vis[i][j])){
            ok=0; break;
        }
    }
    if(not ok) break;
}
if(ok) cout<<"Yes\n";
else cout<<"No\n";

it prints

G

0

Yes

Removing one of break; (or both) gives correct behavior