제출 #1003582

#제출 시각아이디문제언어결과실행 시간메모리
1003582toast12동굴 (IOI13_cave)C++14
100 / 100
564 ms608 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; void exploreCave(int N) { int s[N], d[N]; for (int i = 0; i < N; i++) { s[i] = 0; d[i] = -1; } vector<bool> found(N); // iterate over all doors and find out which switch opens the ith door for (int i = 0; i < N; i++) { // find which switch unlocks door i // first find the position in which door i gets unlocked int x = tryCombination(s); if (x == -1) x = i+1; int pos = 0; if (x <= i) pos = 1; int lo = 0, hi = N-1; while (lo < hi) { int mid = lo+(hi-lo)/2; // check left half for (int j = lo; j <= mid; j++) { if (!found[j]) s[j] = pos; } for (int j = mid+1; j < N; j++) { if (!found[j]) s[j] = 1-pos; } x = tryCombination(s); for (int j = 0; j < N; j++) { if (!found[j]) s[j] = 0; } if (x == -1) x = i+1; if (x > i) { hi = mid; } else { lo = mid+1; } } d[hi] = i; s[hi] = pos; found[hi] = true; // for (int j = 0; j < N; j++) { // if (found[j]) { // cout << j << ": " << s[j] << '\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...