I tested the code with the examples given in the problem statement and it worked correctly but the code fails in submission. Here’s the code -
#include<bits/stdc++.h>
using namespace std;
int main() {
int t,g,i,n,q;
cin >> t;
for(int tc = 0; tc < t; tc++){
cin >> g;
for(int gc = 0; gc < g; gc++){
cin >> i >> n >> q;
if(n % 2 == 0){
cout << n / 2 << endl;
}
else {
if(i == 1)
q == 1 ? cout << int(floor(float(n)/2)) << endl : cout << int(ceil(float(n)/2)) << endl;
else q == 2 ? cout << int(floor(float(n)/2)) << endl : cout << int(ceil(float(n)/2)) << endl;
}
}
}
return 0;
}