比赛 2025暑期集训第6场 评测结果 AAAAAAAAAA
题目名称 Cow Operations 最终得分 100
用户昵称 pcx 运行时间 0.459 s
代码语言 C++ 内存使用 5.16 MiB
提交时间 2025-07-12 09:11:51
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,c[N],o[N],w[N];
string s;
int main(){
    freopen("operation.in","r",stdin);
	freopen("operation.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s>>n;
	int len=s.size();
	for(int i=0;i<len;i++){
		if(s[i]=='C'){
			c[i+1]=c[i]+1;
			o[i+1]=o[i];
			w[i+1]=w[i];
		}else if(s[i]=='O'){
			c[i+1]=c[i];
			o[i+1]=o[i]+1;
			w[i+1]=w[i];
		}else if(s[i]=='W'){
			c[i+1]=c[i];
			o[i+1]=o[i];
			w[i+1]=w[i]+1;
		}
	}
	for(int i=1;i<=n;i++){
		int l,r;
		cin>>l>>r;
		int cc=c[r]-c[l-1];
		int co=o[r]-o[l-1];
		int cw=w[r]-w[l-1];
		if((cw%2)==(co%2)&&(cc%2)!=(co%2)){
			cout<<'Y';
		}else{
			cout<<'N';
		}
	}
	return 0;
}