Need some help about CF498B

Revision en2, by Neutralised, 2022-09-26 13:56:07

Link to the problem

Link to my submissions
(The topmost submissions are for this problem. There are several coding styles because my teammate asked me to give an implementation in his coding style so that he can help me debug more comfortably XD)

All of my submissions got TLE on test #65, However, I don't know why.
After trying several times, I made a datamaker:

#include <bits/stdc++.h>
using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
	const int n=5000; puts("5000 5000");
	for(int i=1;i<=n;++i)
		printf("%d %d\n",49+(rnd()&1),rnd()%10+1);

and uses my teammate's solution to check with mine. (In fact, my fastest submission runs faster than his offline)

After many tests I knew that my solution is correct because no WA. Then I outputted the running time of it and see if it got TLE offline. But unfortunately not(. Below is the result:

(Idk whether you can see this picture. It's showing that I've passed 5300 tests generated by my datamaker offline and none of these tests got TLE. The longest time cost is about 0.6s.)

I've changed all names of variables and arrays that may cause Undefined Behavior (as far as my teammate and I know).
Can anyone tell me why it still got TLE on codeforces? Thanks very much!!!!!!!


  Rev. Lang. By When Δ Comment
en2 English Neutralised 2022-09-26 13:56:07 4
en1 English Neutralised 2022-09-26 13:53:03 1599 Initial revision (published)