比赛 寒假集训4 评测结果 AAAAAAWAAA
题目名称 这是一道橙题 最终得分 90
用户昵称 123 运行时间 1.264 s
代码语言 C++ 内存使用 3.70 MiB
提交时间 2026-02-28 12:46:35
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int qwe;
long long R;
string t;
long long p(long long x)
{
    if (x%4==1) return 1;
    else if (x%4==2) return x+1;
    else if (x%4==3) return 0;
    else return x;
}
long long qw(long long x)
{
    long long ans=0,q=R;
    while (x && x>=(q+1)/2)
    {
        x-=(q+1)/2;
        ans^=p((q+1)/2-1);
        q/=2; 
    }
    ans^=p(x);
    return ans;
}
int main() {
    freopen("orange.in","r",stdin);
    freopen("orange.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>qwe;
    while (qwe--)
    {
        long long n;
        cin>>t>>n;
        if (t[0]=='q')
        {
            long long ans=0;
            while (n--)
            {  
                long long l,r;l++,r++;
                cin>>l>>r;
                ans^=qw(max(0ll,l-1))^qw(r);
            }
            cout<<(ans>0);
        }
        else R=n+1;
    } 
}