Coding Discussions
Would you like to react to this message? Create an account in a few clicks or log in to continue.

DISH OF LIFE SOLUTION

Go down

DISH OF LIFE SOLUTION Empty DISH OF LIFE SOLUTION

Post by akarshsomani Mon Apr 17, 2017 5:28 pm

Code:
import java.util.Scanner;
 
 class dishlife {
   public static void  main(String args[])
   {
      Scanner sc=new Scanner(System.in);
      
      int t=sc.nextInt();
      while(t-->0)
      {
         int count=0;
         int f1=0,f2=0;
         int n=sc.nextInt();
         int k=sc.nextInt();
         int arr[]=new int[k];
         for(int k1=1;k1<=n;k1++)
         {
            int g=sc.nextInt();
            
            while(g-->0)
            {
               int l=sc.nextInt();
               if(arr[l-1]==0)
               {
                  arr[l-1]++;
                  count++;
               }
            }
            if(count==k&&k1!=n)
            {
               f1=1;
            }
            if(count==k&&k1==n)
            {
               f2=1;
            }
         }
         
         if(count!=k)
         {
            System.out.println("sad");
            
         }
         else if(f1==1){
            System.out.println("some");
         }
         else if(f2==1)
         {
            System.out.println("all");
         }
      }
   }
}

akarshsomani

Posts : 21
Join date : 2017-04-04

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum