QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#666810#9518. 观虫我 (旧版数据)wsyear0 0ms0kbC++142.7kb2024-10-22 20:02:112024-10-22 21:31:57

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 21:31:57]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-10-22 20:02:12]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-10-22 20:02:11]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T>inline void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T>inline void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

struct custom_bitset {
  vector<uint64_t> bits;
  int64_t b, n;

  custom_bitset(int64_t _b = 0) {
    init(_b);
  }
 
  void init(int64_t _b) {
    b = _b;
    n = (b + 63) >> 6;
    bits.assign(n, 0);
  }
  
  void kuo(int64_t _b) {
    b = _b;
    n = (b + 63) >> 6;
    while (int(bits.size()) < n) bits.push_back(0LLU);
  }

  void clear() {
    b = n = 0;
    bits.clear();
  }

  void reset() {
    bits.assign(n, 0);
  }
  
  void set() {
    bits.assign(n, -1LLU);
    if (b != 64 * n)
      bits.back() &= (1LLU << (b - 64 * (n - 1))) - 1;
  }
 
  void _clean() {
    // Reset all bits after `b`.
    if (b != 64 * n)
      bits.back() &= (1LLU << (b - 64 * (n - 1))) - 1;
  }
 
  void change(int64_t index) {
    bits[index >> 6] ^= (1LLU << (index & 63));
  }
  
  int64_t count() const {
    int64_t sum = 0;
    for (int i = 0; i < n; i++)
      sum += __builtin_popcountll(bits[i]);
    return sum;
  }
 
  custom_bitset& operator&=(const custom_bitset &other) {
    assert(b == other.b);
 
    for (int i = 0; i < n; i++)
      bits[i] &= other.bits[i];
 
    return *this;
  }
};

const int maxn = 1000010;

struct node {
  ull x;
  int op, ans;
} a[maxn];

int n, m, rnk[maxn], tot;
custom_bitset st[4][1 << 8], res;

int main() {
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  cin >> n >> m;
  rep (i, 1, m) {
    char ch;
    cin >> ch >> a[i].x, a[i].ans = 0;
    a[i].op = (ch == '!');
  }
  rep (i, 1, m) {
    if (a[i].op) {
      rnk[i] = tot++;
      rep (i, 0, 3) rep (j, 0, (1 << 8) - 1) st[i][j].kuo(tot);
      rep (j, 0, 3) {
        ull msk = ((a[i].x >> (j << 3)) & ((1 << 8) - 1)) ^ ((1 << 8) - 1);
        for (ull s = msk; ; s = (s - 1) & msk) {
          st[j][((1 << 8) - 1) ^ s].change(rnk[i]);
          if (!s) break;
        }
      }
    } else if (tot) {
      res.init(tot), res.set();
      rep (j, 0, 3) {
        ull msk = ((a[i].x >> (j << 3)) & ((1 << 8) - 1));
        res &= st[j][msk];
      }
      a[i].ans = (res.count() & 1);
    }
  }
  rep (i, 1, m) if (!a[i].op) cout << a[i].ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

24 1000000
! 9475137
! 4501536
? 14277831
? 16695039
? 5723102
? 6093887
? 3014539
! 475969
? 12500973
! 8750136
? 15617895
! 4589313
! 152300
? 3612579
? 15248179
! 764162
! 4461105
? 7274495
? 13299697
! 8388872
? 13490383
! 3875594
! 9439685
? 16776189
! 6443172
? 13864879
! 395691
? 7142271
? 16...

output:


result:


Subtask #2:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

26 1000000
! 18006034
? 66957270
! 2133064
! 147618
! 34621442
? 49715575
? 62879287
! 18620682
? 67073751
! 62941186
! 7634532
? 67100031
? 12517237
! 4804997
? 65991126
! 138275
? 65722687
? 66043391
! 19147234
? 45743743
! 2242648
! 44378336
? 48226020
! 34341926
! 665045
? 55433083
! 5554254
? 4...

output:


result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #21:

score: 0
Time Limit Exceeded

input:

28 1000000
! 1081468
! 128476263
! 67930241
? 94304031
! 103698752
! 19982
! 198050624
? 249519591
? 71286719
? 255700799
! 103309888
! 819340
! 12852092
? 124739445
? 192734967
! 101320328
! 117594711
? 252032927
! 134267948
? 262940285
! 3155972
? 267876218
! 41984160
? 246413294
? 246824252
? 163...

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #31:

score: 0
Time Limit Exceeded

input:

30 1000000
! 33852274
? 1017904007
? 1046413001
! 151029382
? 466826079
? 250568375
! 6769874
! 2106474
? 536832803
? 209627867
! 167104971
? 1048372157
! 245380745
! 25174496
? 819646460
! 539548800
! 671358165
? 402955591
? 527753201
! 582494209
? 862862931
? 938974695
? 263672827
? 366968669
? 87...

output:


result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #41:

score: 0
Time Limit Exceeded

input:

32 1000000
! 2474971548
! 348268033
? 1055293046
? 3382525679
? 1805515707
? 3210332902
? 2805668987
? 4025974780
! 2217771280
! 176949664
! 4213841344
! 1477473321
? 3150869759
? 2127418041
! 1610631720
! 3624477314
! 2288149532
! 70909964
! 40117153
! 1343751456
? 3758095615
! 513059275
! 31956816...

output:


result: