Submission #1104192

#TimeUsernameProblemLanguageResultExecution timeMemory
1104192IanisCave (IOI13_cave)C++17
100 / 100
232 ms700 KiB
#pragma GCC optimize("Ofast,unroll-loops") #include "cave.h" #include <iostream> using namespace std; const int NMAX = 5005; int n; int a[NMAX]; int ans[NMAX]; int pos[NMAX]; int swi[NMAX]; int query(int s[]) { int q = tryCombination(s); return q == -1 ? n : q; } void make_seq(bool val, short l, short r, int cnt) { fill(a, a + n, !val); fill(a + l, a + r + 1, val); for (int i = 0; i < cnt; i++) { a[swi[i]] = ans[swi[i]]; } } int find_switch(int door) { int l = 0, r = n - 1; bool val = 1; make_seq(1, 0, n - 1, door); if (query(a) <= door) { val = 0; } while (l <= r) { int mid = (l + r) >> 1; make_seq(val, l, mid, door); if (query(a) <= door) { l = mid + 1; } else { r = mid - 1; } } swi[door] = r + 1; ans[r + 1] = val; return r + 1; } void exploreCave(int N) { n = N; for (int i = 0; i < n; i++) { int x = find_switch(i); pos[x] = i; } make_seq(0, n, n, n); answer(a, pos); }
#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...