My code gives right answer for every test case put individually but when I use while(test–) for all test cases ,it starts giving Wrong answers.
Problem :Problem - 1327B - Codeforces
I have used while(test–) and there is no global variable used.
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int main()
{
int t;
cin>>t;
while(t--)
{
int size,n;
unordered_map<int,bool>rishta;
unordered_map<int,bool>confirm;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>size;
int input;
for(int j=0;j<size;j++)
{
cin>>input;
if(rishta[input])
{
continue;
}
else
{
rishta[input]=true;
confirm[i]=true;
break;
}
}
}
int x = -1,y = -1;
for(int k=1;k<=n;k++)
{
if(!confirm[k])
{
y=k;
break;
}
}
for(int k=1;k<=n;k++)
{
if(!rishta[k])
{
x = k;
break;
}
}
if(x!=-1 && y!=-1)
{
cout<<"IMPROVE"<<endl;
cout<<x<<" "<<y<<endl;
}
else
{
cout<<"OPTIMAL"<<endl;
}
}
}