比赛 2025暑期集训第6场 评测结果 AAAAAAAAAA
题目名称 Cow Operations 最终得分 100
用户昵称 Hollow07 运行时间 0.470 s
代码语言 C++ 内存使用 8.45 MiB
提交时间 2025-07-12 08:50:21
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long

string s;
ll sum[200010][5],n;
ll cow[130];

int main(){
	freopen("operation.in","r",stdin);
	freopen("operation.out","w",stdout);
	cin>>s;
	cow['C']=0;cow['O']=1;cow['W']=2;
	sum[0][cow[s[0]]]=1;
	for (int i=1;i<=s.length();i++){
		for (int j=0;j<3;j++) sum[i][j]+=sum[i-1][j];
		sum[i][cow[s[i]]]++;
	}
	scanf("%lld",&n);
	for (int i=1;i<=n;i++){
		ll l,r,cnt=0;
		scanf("%lld %lld",&l,&r);l--;r--;
		ll c,o,w;
		c=sum[r][0]-sum[l-1][0];o=sum[r][1]-sum[l-1][1];w=sum[r][2]-sum[l-1][2];
		if (c&1){
			if ((o&1)||(w&1)) printf("N");
			else printf("Y");
		}else{
			if ((o&1)&&(w&1)) printf("Y");
			else printf("N");
		}
	}
    return 0;
}