Help needed with Dish of life problem

Hi All.

The question is : https://www.codechef.com/problems/DISHLIFE

My solution is

 #include <iostream>
    #include <algorithm>
    #include <unordered_set>

    using namespace std;

    int main()
   {
 
     int T,N,K,P;
     unordered_set<int> In;
     int val;
     bool SOME;
     cin >> T;
     int siz;
     for(int t=0; t<T;t++)
     {
          cin >> N >> K;
	  for(int i=1; i <= N ; i++)
	  {
	     cin >> P;
             siz = In.size();
	     for(int j=0; j < P; j++)
	     {
		 cin >> val;
		 In.insert(val);
	     }
	     if( i <= N && In.size() == K )
	     {
                  SOME = true;
	     }              
	  }
	  if(SOME )
	  {
	     cout << "some" << endl;
             SOME = false;
             In.clear();
             continue;
	  }	
	  if( In.size() == K)
	  {
	     cout << "all" << endl;
	  }	  
	  else if(In.size() != K && In.size() != 0)
	  {
	    cout << "sad" << endl;
	  }
          In.clear();
       }

      return 0;

        }

So I created a lot of random test cases and even cross verified the results with tester/setter solutions and got same output (then i realized the question was changed over the course) and hence checked with an accepted solution and it still failed :frowning:

Can anyone of you help me with what i am missing and why my code fails for few sub tasks? :slight_smile:

Thanks

Ashwath

Your code will fail for these type of test cases :

1

4 4

2 3 4

1 3

1 3

2 1 2

Expected output : some (As the chef can skip the 2nd and 3rd islands)

Your output : all

Hope this helps! :slight_smile:

1 Like