Submission #1145813

#TimeUsernameProblemLanguageResultExecution timeMemory
1145813Shadow1Cave (IOI13_cave)C++20
100 / 100
633 ms528 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int N) { int n = N; int s[n], d[n]; // swtich combination and connected door. vector<bool> know(n); int res = -1; fill(s, s+n, 0); fill(d, d+n, 0); for(int k=0; k<n; ++k) { int l = 0, r = n-1; int q[n]; for(int i=0; i<n; ++i) q[i] = (know[i] ? s[i] : 0); int init = tryCombination(q); bool one = 0; if(init == k) one = true; else one = false; int x = init; // if init > k, correct switch lies somewhere while(l < r) { int m = (l + r) >> 1; for(int i=0; i<n; ++i) { if(know[i]) q[i] = s[i]; else if(i >= l && i <= m) q[i] = (one ? 1 : 0); else q[i] = (one ? 0 : 1); } x = tryCombination(q); if(x == -1) x = n; if(x > k) // door changes state, correct switch on left r = m; else l = m+1; res = x; } // if(k == 1) show(x); s[r] = (one ? 1 : 0); know[r] = true; d[r] = k; } answer(s, d); }
#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...