Chef and calculation :- Help needed

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;
    }

Your code fails on this

Input

1

2

8 2 2 3 3 4 4 5 5

6 1 2 3 4 5 6

Your output : 2

Correct output : tie

Code I used
1 Like

How to stress testing bro

I didn’t do that , I just saw the exact test case on which this code could fail . BTW for stress testing the best way is to check the corner cases like the one with minimum or maximum input value . And if u r unable to find then just try some random test cases .

@Bro can u give ur discord id so that i can learn something new from you
score :9
5->2
4->2
2->2
3->2

score :10
6->1
1->1
2->1
3->1
4->1
5->1

according to logic the output is correct but why it’s tie
i mean

for 1st c : 8 + 1 = 9 (1 is taken bcoz it contain 4 unique cookies)
for 2nd c : 6+4 = 10 (4 is taken bcoz it contain 6 unique cookies)

so 10 > 9 and its index is 2

Chef’s Score is 10 , in 1 box you can put {2,3,4,5} , and in other box you can again put {2,3,4,5} as each no. Occurs twice.