제출 #367787

#제출 시각아이디문제언어결과실행 시간메모리
367787idk321동굴 (IOI13_cave)C++11
100 / 100
1074 ms736 KiB
#include "cave.h" const int N = 5000; int s[N]; int d [N]; bool skip [N]; int n; void change(int to) { for (int i = 0; i <= to; i++) { if (!skip[i]) { s[i] = !s[i]; } } } int bs(bool org, int i) { int a = 0; int b = n - 1; int res = -1; while (a <= b) { int mid = (a + b) / 2; change(mid); bool cgood = false; int cur = tryCombination(s); if (cur == - 1 || cur > i) cgood = true; if (cgood != org) { res = mid; b = mid - 1; } else { a = mid + 1; } change(mid); } return res; } void exploreCave(int N) { n = N; for (int i = 0; i < n; i++) { int cur = tryCombination(s); bool good = false; if (cur == -1 || cur > i) good = true; int ind = bs(good, i); skip[ind] = true; if (!good) s[ind] = !s[ind]; d[ind] = i; } 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...