#include <bits/stdc++.h>
using namespace std;
int main () {
long long int x;
cin>>x;
for(int i=0;i<x;i++){
string s;
cin>>s;long long int c=0,l=0;
for(long long int j=0;j<s.length();j++)
{
if(s[j]=='1')
l++;
}
for(long long int j=0;j<s.length();j++){
if(s[j]=='1')
{
c++;
if(s[j+1]=='0')
break;
}
}
if(l==c&&l!=0)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.