比赛 |
2025暑期集训第6场 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Cow Operations |
最终得分 |
100 |
用户昵称 |
ChenBp |
运行时间 |
3.043 s |
代码语言 |
C++ |
内存使用 |
5.10 MiB |
提交时间 |
2025-07-12 10:01:44 |
显示代码纯文本
#include <iostream>
#include <cstdio>
using namespace std;
const int N=2e5+5;
int s[N][3];
int w(char c){
if(c=='C') return 0;
if(c=='O') return 1;
if(c=='W') return 2;
return 0;
}
int main(){
freopen("operation.in","r",stdin);
freopen("operation.out","w",stdout);
string str;
cin>>str;
int n=str.size();
str=" "+str;
for(int i=1;i<=n;i++){
for(int j=0;j<=2;j++){
s[i][j]=s[i-1][j];
}
s[i][w(str[i])]++;
}
int q;
cin>>q;
while(q--){
int l,r;
cin>>l>>r;
int c=s[r][0]-s[l-1][0];c%=2;
int o=s[r][1]-s[l-1][1];o%=2;
int w=s[r][2]-s[l-1][2];w%=2;
if(!c&&!o&&!w) cout<<"N";
if(c&&!o&&!w) cout<<"Y";
if(!c&&o&&!w) cout<<"N";
if(!c&&!o&&w) cout<<"N";
if(c&&o&&!w) cout<<"N";
if(c&&!o&&w) cout<<"N";
if(!c&&o&&w) cout<<"Y";
if(c&&o&&w) cout<<"N";
}
}