编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#24186 #1001. A. 神秘谜题 Accepted 100 343 ms 20772 K C++ 11 / 1.2 K 电类911-何宇恒 2020-04-13 10:18:26
显示原始代码
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXM = 31;
const int MAXN = 2 * 1e5;

int n;
int bcnt[MAXM + 5], tcnt = 1;
struct Node {
    int cnt, nxt[2];
} T[MAXN * MAXM + 5];

void Insert(int u, int x, int d) {
    if (d > MAXM)
        return;
    T[u].cnt++;
    if (x & 1)
        bcnt[d]++;
    if (!T[u].nxt[(x >> 1) & 1])
        T[u].nxt[(x >> 1) & 1] = ++tcnt;
    Insert(T[u].nxt[(x >> 1) & 1], x >> 1, d + 1);
    return;
}

void Add(int u, int d) {
    if (d > MAXM)
        return;
    if (T[u].nxt[1])
        Add(T[u].nxt[1], d + 1);
    if (T[u].nxt[0])
        bcnt[d] += T[T[u].nxt[0]].cnt;
    if (T[u].nxt[1])
        bcnt[d] -= T[T[u].nxt[1]].cnt;
    swap(T[u].nxt[0], T[u].nxt[1]);
}

inline int Query() {
    int res = 0;
    for (int i = 0; i < MAXM; ++i) res |= (bcnt[i] & 1) << i;
    return res;
}

int main() {
    scanf("%d", &n);
    int opt, x;
    while (n--) {
        scanf("%d", &opt);
        if (opt == 1) {
            if (T[1].cnt)
                Add(1, 1);
            bcnt[0] += T[0].cnt - T[1].cnt;
            swap(T[0], T[1]);
        } else {
            scanf("%d", &x);
            Insert(x & 1, x, 0);
        }
        printf("%d\n", Query());
    }
    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:183 ms
内存:20772 KiB

输入文件(1.in

200000
2 526767110
2 724642759
2 567837900
2 104106873
2 357915481
2 33997211
2 444788944
2 
<1586974 bytes omitted>

答案文件(1.ans

526767110
877985729
361528077
330887284
116239149
82537142
510237286
843295274
453728745
55
<2188330 bytes omitted>

用户输出

526767110
877985729
361528077
330887284
116239149
82537142
510237286
843295274
453728745
559263713
323554710
713540578
520942594
<1988302 bytes omitted>

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:160 ms
内存:20724 KiB

输入文件(2.in

200000
2 515979308
2 512702340
2 684230440
2 488136957
2 598252313
2 283603971
2 349877373
2
<1586842 bytes omitted>

答案文件(2.ans

515979308
5115816
679905408
899606653
372667236
114362215
302756634
473674072
520218589
525
<2192841 bytes omitted>

用户输出

515979308
5115816
679905408
899606653
372667236
114362215
302756634
473674072
520218589
525056845
703148326
764590712
207056035

<1992813 bytes omitted>

系统信息

Exited with return code 0