Submission #68431

#TimeUsernameProblemLanguageResultExecution timeMemory
68431KubalionzzaleCave (IOI13_cave)C++14
100 / 100
1540 ms528 KiB
#include "cave.h" bool visited[5010] = { 0 }; int s[5010] = { 0 }, d[5010] = { 0 }; int check[5010] = { 0 }; int n; void solve(int index, int l, int r, int swit) { if (l == r) { d[l] = index; s[l] = swit; visited[l] = 1; return; } int mid = l + (r - l) / 2; for (int i = 0; i < n; ++i) { if (visited[i]) check[i] = s[i]; else check[i] = !swit; } for (int i = l; i <= mid; ++i) { if (!visited[i]) check[i] = swit; } int cur = tryCombination(check); if (cur == -1 || cur > index) solve(index, l, mid, swit); else solve(index, mid + 1, r, swit); } void exploreCave(int N) { n = N; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (visited[j]) check[j] = s[j]; else check[j] = 0; } int cur = tryCombination(check); int key; if (cur == -1 || cur > i) key = 0; else key = 1; solve(i, 0, n - 1, key); } 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...