Hi,↵
↵
In the latest [Division 2 round](https://codeforces.net/contest/2004), I submitted the [hyperlinked code](https://codeforces.net/contest/2004/submission/276587089) (276587089) for Problem B. The strategy was simply to create two arrays $A$ and $B$ of size $100$ each, initialise them with zeros and set $A[i]=1$ such that $l \le I \le r$; and analogously for the array $B$. Then, I would iterate through each position $p$ in $A$ and increment a counter whenever $B[p-1]=1$ or $B[p+1]=1$. Evidently, this method is prone to counting the same door twice, so I kept a set of pairs to eliminate duplicates. At the end, I simply printed the size of the set.↵
↵
I ran the example tests on my machine, and it did produce the correct results. Alas, the website's C++20 compiler did not produce the same output my machine did. As you can see, CodeForces' compiler produced the following:↵
↵
~~~~~↵
2↵
4↵
3↵
4↵
~~~~~↵
↵
It is even more bizarre considering that the C++17 compiler produced a different result for the same code. However, my computer did produce valid outputs, as evidenced by that screenshot:↵
↵
(I hope the upload will be clear):↵
↵
![ ](/predownloaded/98/ca/98cac2bd49d4f3949d0aaa3dff0b169f5db63baf.png)↵
↵
Since the compiler repeatedly produced outputs contradicting mine, I had to go with a different approach for B.↵
↵
What exactly went wrong? What could I do to prevent that problem from occurring in the future?↵
↵
Thank you,↵
Kind regards.
↵
In the latest [Division 2 round](https://codeforces.net/contest/2004), I submitted the [hyperlinked code](https://codeforces.net/contest/2004/submission/276587089) (276587089) for Problem B. The strategy was simply to create two arrays $A$ and $B$ of size $100$ each, initialise them with zeros and set $A[i]=1$ such that $l \le I \le r$; and analogously for the array $B$. Then, I would iterate through each position $p$ in $A$ and increment a counter whenever $B[p-1]=1$ or $B[p+1]=1$. Evidently, this method is prone to counting the same door twice, so I kept a set of pairs to eliminate duplicates. At the end, I simply printed the size of the set.↵
↵
I ran the example tests on my machine, and it did produce the correct results. Alas, the website's C++20 compiler did not produce the same output my machine did. As you can see, CodeForces' compiler produced the following:↵
↵
~~~~~↵
2↵
4↵
3↵
4↵
~~~~~↵
↵
It is even more bizarre considering that the C++17 compiler produced a different result for the same code. However, my computer did produce valid outputs, as evidenced by that screenshot
↵
↵
![ ](/predownloaded/98/ca/98cac2bd49d4f3949d0aaa3dff0b169f5db63baf.png)↵
↵
Since the compiler repeatedly produced outputs contradicting mine, I had to go with a different approach for B.↵
↵
What exactly went wrong? What could I do to prevent that problem from occurring in the future?↵
↵
Thank you,↵
Kind regards.