比赛 2025暑期集训第6场 评测结果 AAAAAAAAAA
题目名称 Cow Operations 最终得分 100
用户昵称 秋_Water 运行时间 0.386 s
代码语言 C++ 内存使用 5.19 MiB
提交时间 2025-07-12 09:01:55
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
string s,ans;
int q,l,r,cnt1[N],cnt2[N],cnt3[N];
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); }
    while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + c - '0'; c = getchar(); }
    return x * f;
}
int main(){
     freopen("operation.in","r",stdin);
     freopen("operation.out","w",stdout);
    cin>>s;
    q=read();
    for(int i=0;i<s.size();i++){
        cnt1[i+1]=cnt1[i]+(s[i]=='C');
        cnt2[i+1]=cnt2[i]+(s[i]=='O');
        cnt3[i+1]=cnt3[i]+(s[i]=='W');
    }
    for(int i=1;i<=q;i++){
        l=read();
        r=read();
        if((cnt2[r]-cnt2[l-1])%2==(cnt3[r]-cnt3[l-1])%2){
            if((cnt1[r]-cnt1[l-1])%2!=(cnt2[r]-cnt2[l-1])%2){
                ans+="Y";
            }
            else{
                ans+="N";
            }
        }
        else{
            ans+="N";
        }
    }

    cout<<ans;
    return 0;
}