编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#1607 #1001. A. 神秘谜题 Compile Error 0 0 ms 0 K C++ / 1.5 K q3540555 2019-06-25 11:23:39
显示原始代码
#include <map>
#include <ctime>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define scanf scanf_s
using namespace std;

struct trp {
    int lrp[2];
    bool dta;
};

int tn, oc, onm, nwp = 0, ntp = 0;
int pows[32], sum[32];
vector<trp> wtr;

void adep() { wtr.push_back(trp({ { -1, -1 }, 0 })); }

void adp(int onm) {
    for (int i = 0; i < 32; i++) {
        int lnm = (onm / pows[i]) % 2;
        if (wtr.at(nwp).lrp[lnm] == -1) {
            wtr.at(nwp).lrp[lnm] = ++ntp;
            adep();
            nwp = ntp;
            wtr.at(nwp).dta ^= 1;
        } else {
            nwp = wtr.at(nwp).lrp[lnm];
            wtr.at(nwp).dta ^= 1;
        }
        if (lnm)
            sum[i] ^= 1;
    }
    nwp = 0;
}

void aoap() {
    for (int i = 0; i < 32; i++) {
        swap(wtr.at(nwp).lrp[0], wtr.at(nwp).lrp[1]);
        if (wtr.at(nwp).lrp[1] != -1)
            sum[i] ^= wtr.at(wtr.at(nwp).lrp[1]).dta;
        nwp = wtr.at(nwp).lrp[0];
        if (nwp == -1)
            break;
        sum[i] ^= wtr.at(nwp).dta;
    }
    nwp = 0;
}

int uda() {
    int ans = 0;
    for (int i = 0; i < 32; i++) ans += sum[i] * pows[i];
    return ans;
}

int main() {
    adep();
    pows[0] = 1;
    for (int i = 0; i < 32; i++) sum[i] = 0;
    for (int i = 1; i < 32; i++) pows[i] = 2 * pows[i - 1];
    scanf("%d", &tn);
    for (int i = 0; i < tn; i++) {
        scanf("%d", &oc);
        if (oc == 1) {
            aoap();
        } else {
            scanf("%d", &onm);
            adp(onm);
        }
        printf("%d\n", uda());
    }
    system("pause");
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'void adep()':
/sandbox/1/a.cpp:26:20: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  wtr.push_back(trp({ {-1, -1}, 0 }));
                    ^
/sandbox/1/a.cpp:26:35: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
  wtr.push_back(trp({ {-1, -1}, 0 }));
                                   ^
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:11:15: error: 'scanf_s' was not declared in this scope
 #define scanf scanf_s
               ^~~~~~~
/sandbox/1/a.cpp:83:2: note: in expansion of macro 'scanf'
  scanf("%d", &tn);
  ^~~~~
/sandbox/1/a.cpp:11:15: note: suggested alternative: 'scanf'
 #define scanf scanf_s
               ^~~~~~~
/sandbox/1/a.cpp:83:2: note: in expansion of macro 'scanf'
  scanf("%d", &tn);
  ^~~~~
/sandbox/1/a.cpp:98:8: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
  system("pause");
  ~~~~~~^~~~~~~~~