编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#47268 #1001. A. 神秘谜题 Accepted 100 335 ms 75536 K C++ / 1.0 K 17868801762 2021-03-20 9:43:12
显示原始代码
#include <cstdio>
#include <cstdlib>
using namespace std;
struct QQ {
    bool num;
    int lc, rc;
    QQ() {
        num = false;
        lc = rc = 0;
    }
} a[6400000];
int tail = 0;
int ans = 0;
void work1()  //加一
{
    int cen = 0, p = 0, x;
    while (a[p].lc || a[p].rc) {
        if (a[a[p].lc].num != a[a[p].rc].num) {
            ans ^= (1 << cen);
        }
        {
            x = a[p].lc;
            a[p].lc = a[p].rc;
            a[p].rc = x;
        }
        p = a[p].lc;
        if (!p)
            break;
        cen++;
    }
    printf("%d\n", ans);
}
void work2()  //插入
{
    int x, i, p, cen;
    scanf("%d", &x);
    p = 0;
    cen = 0;
    while (cen < 30) {
        i = x & 1;
        x >>= 1;
        if (i) {
            if (!a[p].rc) {
                a[p].rc = ++tail;
            }
            p = a[p].rc;
            a[p].num = !a[p].num;
            ans ^= (1 << cen);
        } else {
            if (!a[p].lc) {
                a[p].lc = ++tail;
            }
            p = a[p].lc;
            a[p].num = !a[p].num;
        }
        cen++;
    }
    printf("%d\n", ans);
}
void read() {
    int n, i, j;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &j);
        if (j == 1)
            work1();
        else
            work2();
    }
}
int main() { read(); }
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:170 ms
内存:75508 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
用时:165 ms
内存:75536 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