Codeforces и Polygon могут быть недоступны в период с 23 мая, 7:00 (МСК) по 23 мая, 11:00 (МСК) в связи с проведением технических работ. ×

Weird behaviour with GNU G++ 20

Правка en1, от TheBhediyaOfDalalStreet, 2023-01-05 21:05:50

Pardon my choice for variable naming (I was projecting), but I fail to understand why the same code gives me WA with G++20 but AC with G++17

G++20: https://codeforces.com/contest/1768/submission/188128207 G++ 17: https://codeforces.com/contest/1768/submission/188129998

Further, on debugging with G++20 for the case:

1
2
2 2

I found that mysteriously, a[0] becomes equal to 1 after the following for loop from the code is executed:

        for(int i = 1; i <= n; i ++) {
           if(cnt[i] > 2) {
                pos = 0;
                break;
            }
            if(cnt[i] == 2) {
                if(no_bitches.empty() || *no_bitches.begin() > i) {
                    pos = 0;
                    break;
                }
                dual[i] = *no_bitches.begin();
                no_bitches.erase(no_bitches.begin());
            }
        }

You can try it on custom invocation too. I don't change the input array a after taking in input, so I don't know how that happens... Can anyone explain?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский TheBhediyaOfDalalStreet 2023-01-05 21:05:50 1103 Initial revision (published)