It passing only single test case but i m pretty sure that my logic and code is correct…
Problem Link : RESCALC Problem - CodeChef
My Logic
using namespace std;
using ll = long long;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1e9+7;
void init_code()
{
fast_io;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
int n;
cin>>n;
int score,idx=0;
vector<int> v;
unordered_map<int,int> m;
vector<int> result(n+1);
int maxi = INT_MIN;
int count = 0;
for(int i=1;i<=n;i++)
{
int c;
cin>>c;
score = 0;
v.resize(c+1);
idx = 0;
for(int i=1;i<=c;i++)
{
int x;
cin>>x;
v[i] = x;
m[v[i]]++;
}
int sz = m.size();
if(sz <= 3)
{
score = c;
}
else if(sz == 4)
{
score = c+1;
}
else if(sz ==5)
{
score = c+2;
}
else if(sz == 6)
{
score = c+4;
}
result[i] = score;
m.clear();
}
for(int i=2;i<=n;i++)
{
if(result[i] == result[i-1])
{
count++;
}
}
for(int i=1;i<=n;i++)
{
maxi = max(maxi,result[i]);
if(maxi == result[i])
{
idx = i;
}
}
if(count >= 2)
{
cout<<"tie"<<"\n";
}
else if(maxi == result[1])
{
cout<<"chef"<<"\n";
}
else
{
cout<<idx<<"\n";
}
}
int main()
{
init_code();
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}