Submission #674274

#TimeUsernameProblemLanguageResultExecution timeMemory
674274rainboyMinerals (JOI19_minerals)C++17
75 / 100
31 ms2540 KiB
#include "minerals.h" const int N = 43000, L = 16; int k; int Query_(int i) { int k_ = Query(i + 1); if (k_ == k) return 0; k = k_; return 1; } int tt[N * 2], ii[2][N], ii_[1 << L], nn[2], aa[N], bb[N]; void Solve(int n) { k = 0; for (int i = 0; i < n * 2; i++) { tt[i] = !Query_(i); ii[tt[i]][nn[tt[i]]++] = i; } for (int i = 0; i < n; i++) { int a = 0, c = 1; for (int l = 0; l < L; l++) { if ((i & 1 << l) != 0) c ^= 1; if (c) a |= 1 << l; } aa[i] = a; } for (int l = 0; l < L; l++) { for (int i = 0; i < n; i++) if ((aa[i] >> l & 1) != (l == 0 ? 1 : (aa[i] >> l - 1 & 1))) Query_(ii[0][i]); for (int i = 0; i < n; i++) if (!Query_(ii[1][i])) bb[i] |= 1 << l; } for (int i = 0; i < n; i++) ii_[aa[i]] = ii[0][i]; for (int i = 0; i < n; i++) Answer(ii_[bb[i]] + 1, ii[1][i] + 1); }

Compilation message (stderr)

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:35:54: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   35 |    if ((aa[i] >> l & 1) != (l == 0 ? 1 : (aa[i] >> l - 1 & 1)))
      |                                                    ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...