比赛 2025暑期集训第6场 评测结果 AAAAAAAAAA
题目名称 Cow Operations 最终得分 100
用户昵称 Ruyi 运行时间 2.982 s
代码语言 C++ 内存使用 5.15 MiB
提交时间 2025-07-12 09:11:29
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s;
int n,q,l,r,c[300001],o[300001],w[300001];
int main(){
    freopen("operation.in","r",stdin);
    freopen("operation.out","w",stdout);
    cin>>s>>q;
    n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='C') c[i+1]++;
        else if(s[i]=='O') o[i+1]++;
        else w[i+1]++;
        c[i+1]+=c[i];
        o[i+1]+=o[i];
        w[i+1]+=w[i];
    }
    while(q--){
        cin>>l>>r;
        int x=c[r]-c[l-1],y=o[r]-o[l-1],z=w[r]-w[l-1];
        x%=2;
        y%=2;
        z%=2;
        if(x==1&&y==1&&z==1) cout<<'N';
        else if(x==1&&y==1&&z==0) cout<<'N';
        else if(x==1&&y==0&&z==0) cout<<'Y';
        else if(x==1&&y==0&&z==1) cout<<'N';
        else if(x==0&&y==0&&z==1) cout<<'N';
        else if(x==0&&y==1&&z==1) cout<<'Y';
        else if(x==0&&y==1&&z==0) cout<<'N';
        else cout<<'N';
    }
    return 0;
}