比赛 |
2025暑期集训第6场 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Cow Operations |
最终得分 |
100 |
用户昵称 |
汐汐很希希 |
运行时间 |
1.085 s |
代码语言 |
C++ |
内存使用 |
5.24 MiB |
提交时间 |
2025-07-12 09:28:27 |
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
int n,qc[N],qo[N],qw[N];
string s,ans;
int main()
{
freopen("operation.in","r",stdin);
freopen("operation.out","w",stdout);
cin>>s;
cin>>n;
s=" "+s;
for(int i=1;i<=n;i++){
qc[i]=qc[i-1],qo[i]=qo[i-1],qw[i]=qw[i-1];
if(s[i]=='C') qc[i]++;
if(s[i]=='O') qo[i]++;
if(s[i]=='W') qw[i]++;
}
for(int i=1;i<=n;i++)
{
int l,r;
cin>>l>>r;
int c=qc[r]-qc[l-1],o=qo[r]-qo[l-1],w=qw[r]-qw[l-1];
c=c%2,o=o%2,w=w%2;
if(c==1&&o==0&&w==0) ans+="Y";
else if(c==0&&o==1&&w==1) ans+="Y";
else ans+="N";
}
cout<<ans<<endl;
return 0;
}