Hello sirs
Today I submitted a code on Codeforces on the problem 1715D - 2+ doors using the GNU G++17 compiler. Here is the submission link: 324289603.
However, it failed to compile and threw compilation error, the error message saying:
This is the first time anything like this has happened with me, and it fascinated me that such a simple code with no 'modern' features breaks the G++ compiler easily, so I'm sharing it will you all.
Do note that my code doesn't strictly follow the C++17 standard, as I'm declaring an array using a non-constexpr int variable, which is a compiler extension provided by the G++ compiler, not supported by the C++17 standard.
When I changed the code to follow the standard, by declaring a constant size array irrespective of the value of $$$n$$$, it compiles fine: 324293933.
(Also it gives TLE, idk why, since I think the complexity is $$$O(30*(n+q))$$$, so if anyone can help in that I would be eternally thankful to you.)









I think its because you're initializing a variable sized object using the braces '{}' for the arrays 'marked' and 'ans', which is not allowed.
My LSP throws a warning saying "variable sized object may not be initialized" when I view your code locally. Also found something on stack overflow regarding the same: Link
I resubmitted it, keeping the VLAs, but using
std::memsetafter declaring them and it works fine: 324317141