Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- ios::sync_with_stdio(0),cin.tie(0);
- int T,i,n;
- int sum,cmd;
- string str;
- for(cin>>T;T;T--){
- cin>>str;
- n=str.size();
- cmd=sum=0;
- for(i=n-1;i>=0;i--){
- if(str[i]=='1'){
- if(cmd==0){
- sum+=1;
- }else if(cmd==1){
- sum+=2;
- }
- }
- cmd=cmd^1;
- }
- if(sum%3){
- cout<<"No\n";
- }else{
- cout<<"Yes\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement