比赛 |
2025暑期集训第6场 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Cow Operations |
最终得分 |
100 |
用户昵称 |
惊世猴人 |
运行时间 |
2.858 s |
代码语言 |
C++ |
内存使用 |
5.12 MiB |
提交时间 |
2025-07-12 10:02:53 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int t[3][200001];
string s;
int q;
void solve(int xb){
switch(s[xb-1]){
case 'C':t[0][xb]=t[0][xb-1]+1,t[1][xb]=t[1][xb-1],t[2][xb]=t[2][xb-1];break;
case 'O':t[0][xb]=t[0][xb-1],t[1][xb]=t[1][xb-1]+1,t[2][xb]=t[2][xb-1];break;
case 'W':t[0][xb]=t[0][xb-1],t[1][xb]=t[1][xb-1],t[2][xb]=t[2][xb-1]+1;break;
default :exit(2147438647);
}
}
int main(){
freopen("operation.in","r",stdin);
freopen("operation.out","w",stdout);
cin>>s;
cin>>q;
for(int i=1;i<=s.size();i++){
solve(i);
}
int l,r;
for(int i=1;i<=q;i++){
cin>>l>>r;
if((t[1][r]-t[1][l-1])%2==(t[2][r]-t[2][l-1])%2){
int x=t[0][r]-t[0][l-1]+min(t[1][r]-t[1][l-1],t[2][r]-t[2][l-1]);
if(x%2==0)putchar('N');
else putchar('Y');
}else{
putchar('N');
}
}
fclose(stdin);
fclose(stdout);
return 0;
}