Agniva_'s blog

By Agniva_, history, 8 months ago, In English

Problem Link 254383531

void solve(){
   int n; cin>>n;
   vi v(n); rep(i,0,n) cin>>v[i];
   int flag=1;
   rep(i,0,n/2){
     if(v[i]!=v[n-1-i]) {
        flag=0; break;
     }
   } 
   if(flag){
    yes
    return;
   }
   string s="";
   for(int i=0;i<n;i++) 
     if(v[i]!=v[0]) s=s+to_string(v[i]);
    string s2=s;
    reverse(s2.begin(),s2.end());
    if(s==s2) 
    {
        yes return;
    }
    s="";
    for(int i=0;i<n;i++) 
     if(v[i]!=v[n-1]) s=s+to_string(v[i]);
    s2=s;
    reverse(s2.begin(),s2.end());
    if(s==s2) 
    {
        yes return;
    }
    no 
}

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it