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

int main() {
	freopen("operation.in","r",stdin);
	freopen("operation.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;
    int Q;
    cin >> Q;

    int n = s.size();
    vector<int> a0(n + 1, 0);
    vector<int> b0(n + 1, 0);

    for (int i = 0; i < n; ++i) {
        a0[i + 1] = a0[i];
        b0[i + 1] = b0[i];
        if (s[i] == 'C') {
            a0[i + 1] ^= 1;
        } else if (s[i] == 'O') {
            b0[i + 1] ^= 1;
        } else if (s[i] == 'W') {
            a0[i + 1] ^= 1;
            b0[i + 1] ^= 1;
        }
    }

    string ans;
    while (Q--) {
        int l, r;
        cin >> l >> r;
        int a = a0[r] ^ a0[l - 1];
        int b = b0[r] ^ b0[l - 1];
        ans += (a == 1 && b == 0) ? 'Y' : 'N';
    }

    cout << ans << '\n';
    return 0;
}