Submission #417484

#TimeUsernameProblemLanguageResultExecution timeMemory
417484dxz05Cave (IOI13_cave)C++14
0 / 100
293 ms460 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int N) { int comb[N], S[N], D[N]; fill(S, S + N, -1); vector<int> free(N); for (int i = 0; i < N; i++) free.push_back(i); for (int i = 0; i < N; i++){ int ind = 0; for (int j = 0; j < N; j++){ comb[j] = (S[j] != -1 ? S[j] : 0); } int x = (tryCombination(comb) == i); int l = 0, r = free.size() - 1; while (l <= r){ int mid = (l + r) >> 1; for (int j = 0; j < N; j++){ comb[j] = (S[j] != -1 ? S[j] : (x ^ 1)); } comb[free[mid]] = x; if (tryCombination(comb) != i){ ind = mid; r = mid - 1; } else l = mid + 1; } int pos = free[ind]; //cout << x << ' ' << pos << endl; S[pos] = x; D[pos] = i; free.erase(free.begin() + ind); } answer(S, D); } /* 4 1 1 1 0 3 1 0 2 */
#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...