Submission #663344

#TimeUsernameProblemLanguageResultExecution timeMemory
663344AlmaCave (IOI13_cave)C++17
100 / 100
832 ms692 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; const int MX = 5000; int S[MX], D[MX], A[MX], idx[MX]; void exploreCave(int N) { memset(S, 0, sizeof S); memset(D, -1, sizeof D); for (int n = 0; n < N; n++) { for (int i = 0; i < N; i++) { if (D[i] != -1) { A[i] = idx[D[i]]; } else { A[i] = 1; } } int ret = tryCombination(A); int target; if (ret == n) { target = 0; } else { target = 1; } int lo = 0, mid, res = -1, hi = N-1; while (lo <= hi) { mid = (lo+hi) / 2; for (int i = 0; i < N; i++) { if (D[i] != -1) continue; if (i <= mid) { A[i] = target; } else { A[i] = 1 - target; } } ret = tryCombination(A); if (ret == n) { lo = mid+1; } else { res = mid; hi = mid-1; } } idx[n] = target; S[res] = target; D[res] = n; } 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...