It has probably happened to everyone that they try to solve a problem, but get a WA (Wrong Answer) or TLE (Time Limit Exceeded) on one of the tests. They want to find the specific test case where their code failed, but in many cases, that test case cannot be found on the submission page.
But...
I’ve found a good solution to this problem. It’s possible that we can’t find the test case on the input page, but we can find it on the output page of our own code. This can be done by making our code’s output correspond to only that single test case.
Like in the following code:
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int Tc;
cin >> Tc;
int Cnt_Tc = Tc; // Count of test cases
bool Tcc = false; // If you want to know which test case that is
int F_Tc = 352; // The test case where your code failed
while(Tc--) {
if(Tc == Cnt_Tc - F_Tc && Tcc){
/*
Print input
*/
int n;
cin >> n;
vector<int> a(n);
for(auto &x : a) cin >> x;
cout << n << endl;
for(auto &x : a) cout << x << " ";
cout << endl;
}
else if(!Tcc){
/*
Main code
*/
int n;
cin >> n;
vector<int> a(n);
for(auto &x : a)cin >> x;
int s = 0;
for(auto &x : a)s += x;
cout << s << endl;
}
else{
/*
Just cin extra input
*/
int n;
cin >> n;
vector<int> extra(n);
for(auto &x : extra) cin >> x;
}
}
return 0;
}








