Submission #56379

#TimeUsernameProblemLanguageResultExecution timeMemory
56379aquablitz11Cave (IOI13_cave)C++14
0 / 100
310 ms640 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; const int N = 5010; int n, S[N], P[N], Q[N]; void recur(int l, int r, int d, bool ori) // close = 1, open = 0 { if (l == r) { P[l] = d; S[l] = ori ? 1 : 0; } else { int m = (l+r)/2; for (int i = l; i <= m; ++i) { if (S[i] == -1) Q[i] = 1; } for (int i = m+1; i <= r; ++i) { if (S[i] == -1) Q[i] = 0; } bool ret = tryCombination(Q) <= d; if (ori == ret) recur(m+1, r, d, ori); else recur(l, m, d, ori); } } void find_ans(int d) { for (int i = 0; i < n; ++i) Q[i] = max(0, S[i]); recur(0, n-1, d, tryCombination(Q) <= d); } void exploreCave(int n) { ::n = n; for (int i = 0; i < n; ++i) P[i] = S[i] = -1; for (int i = 0; i < n; ++i) find_ans(i); answer(S, P); }
#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...