Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.0 kB
5
Indexable
Never
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t!=0){
		    t--;
		    int m=sc.nextInt();
		    String s=sc.next();
		    int c=0;
		    for(int i=0;i<s.length();i++){
		        int p=s.charAt(i)-'0';
		        if(p==1){
		            c++;
		        }
		    }
		    int g=c;
		    for(int i=0;i<s.length();i++){
		        int u=(s.charAt(i)-'0');
		        if(u==0){
		            System.out.println("NO");
		            if(c==0 && g!=0){
		                break;
		            }
		        }else{
		            c=c-1;
		            if(c==0 && g>=3){
		                System.out.println("YES");
		            }else{
		                System.out.println("IDK");
		            }
		        }
		    }
		        
		}
	}
}
Leave a Comment