제출 #209685

#제출 시각아이디문제언어결과실행 시간메모리
209685my99n동굴 (IOI13_cave)C++14
0 / 100
7 ms896 KiB
#include <bits/stdc++.h> #include "cave.h" void exploreCave(int n) { // ith switch connected to door d[i] // door i connected to s[i] // correct condition of switch i is cc[i] int d[n], s[n], cc[n]; for (int i = 0; i < n; i++) { // find door i answer int c[n]; for (int j = 0; j < i; j++) c[s[j]] = cc[s[j]]; int res = tryCombination(c); assert(res >= i or res == -1); int cond = (res > i or res == -1) ? 0 : 1; int l = 0, r = n-1; while (l < r) { int mid = (l+r)/2; for (int j = 0; j <= mid; j++) c[j] = cond; for (int j = 0; j <= mid; j++) c[j] = cond^1; for (int j = 0; j < i; j++) c[s[j]] = cc[s[j]]; int res = tryCombination(c); assert(res >= i or res == -1); if (res > i or res == -1) r = mid; else l = mid+1; } // switch l control door i d[l] = i; s[i] = l; cc[l] = cond; } assert(tryCombination(cc) == -1); answer(cc, 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...