Submission #987636

#TimeUsernameProblemLanguageResultExecution timeMemory
987636TsaganaCave (IOI13_cave)C++14
100 / 100
837 ms800 KiB
#include "cave.h" #include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define pq priority_queue #define lb lower_bound #define ub upper_bound #define pb push_back #define eb emplace_back #define F first #define S second using namespace std; bitset<5069> spc; int n, a[5001], sq[5001]; int qr(int ky, int x) { for (int i = 0; i < n; i++) { if (sq[i] < n) a[i] = spc[sq[i]]; else a[i] = ky ^ i <= x; } return tryCombination(a); } void exploreCave(int N) { int rh, md, zz; n = N; for (int i = 0; i < n; i++) sq[i]=n; for (int i = 0; i < n; i++) { spc[i] = (qr(1, n-1) == i); for (int lh = 0, rh = n-1; lh <= rh;) { md = (lh + rh) / 2; if (qr(spc[i], md) == i) {zz = md; rh = md-1;} else lh = md + 1; } sq[zz] = i; } for (int i = 0; i < n; i++) a[i] = spc[sq[i]]; answer(a, sq); }

Compilation message (stderr)

cave.cpp: In function 'int qr(int, int)':
cave.cpp:22:28: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   22 |         else a[i] = ky ^ i <= x;
      |                          ~~^~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:27:9: warning: unused variable 'rh' [-Wunused-variable]
   27 |     int rh, md, zz; n = N;
      |         ^~
cave.cpp:36:16: warning: 'zz' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |         sq[zz] = i;
      |         ~~~~~~~^~~
#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...