Help me in solving LONGSEQ problem

My issue

My code

#include<iostream>
#include<string>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int x=0,y=0;
        for(int i=0;i<s.length();i++){
            if(s[i]=='1'){
                x++;
            }
            else{
                y++;
            }
        }
        if(x==1 || y==1){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    
}

Problem Link: LONGSEQ Problem - CodeChef
why this is showing wrong