Today, I submitted a code on Codeforces, and it got a WA on test 2. When I looked up what is wrong with my code, 312665141 it says "wrong answer 5th numbers differ — expected: '3', found: '6' ", but when I try my code on compiler, it gave me actual value. So, how can I fix it?








Please check if there are undefined behaviors in your code.
Sorry, I didn't get it, what do you mean by undefined behaviors?
Check it on wikipedia.
mango mango
you didn't reset the used array, maybe that is the only issue
instead of this, I used a pointer for every testcase, which works for graph problems and helps to decrease time complexity
The problem with using arrays to track whether an index has been "used" is that, instead of using bool, you should mark the index with a variable (e.g., TIME or c in your case) using int or long long.
Your submission gets TL verdict after applying the fix.
submission