제출 #711948

#제출 시각아이디문제언어결과실행 시간메모리
711948thimote75Cave (IOI13_cave)C++14
51 / 100
438 ms548 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; #define MAX_N 5000 int currentDoor = 0; static int S[MAX_N]; static int F[MAX_N]; static int D[MAX_N]; int nbSwitch; void makeCombination (int left, int right, int t0, int t1) { for (int i = 0; i < nbSwitch; i ++) { if (F[i] != -1) S[i] = F[i]; else S[i] = left <= i && i <= right ? t1 : t0; } } int tryComb (int left, int right, int t0, int t1) { makeCombination(left, right, t0, t1); int v = tryCombination(S); if (v == -1) return nbSwitch + 1; return v; } int getValid (int door) { return tryComb(0, nbSwitch - 1, 0, 1) > door ? 1 : 0; } int getDoor (int door, int target) { int n_target = 1 - target; int a = 0; int b = nbSwitch - 1; while (a + 1 < b) { int c = (a + b) >> 1; if (tryComb(a, c, n_target, target) > door) { b = c; } else { a = c; } } return tryComb(a, a, n_target, target) > door ? a : b; } #define di pair<int, int> di getDoor (int door) { int target = getValid(door); return { getDoor(door, target), target }; } void solve (int door) { di data = getDoor(door); int idSwitch = data.first; F[idSwitch] = data.second; D[idSwitch] = door; } void exploreCave(int N) { nbSwitch = N; for (int i = 0; i < N; i ++) F[i] = -1; // Signifies that it is not fixed for (int i = 0; i < N; i ++) solve(i); answer(F, 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...