제출 #648041

#제출 시각아이디문제언어결과실행 시간메모리
648041Clan328동굴 (IOI13_cave)C++17
0 / 100
54 ms448 KiB
#include "cave.h" #include "bits/stdc++.h" using namespace std; typedef vector<int> vi; #define DOWN 1 #define UP 0 #define NA 2 int n; vi dir; int check(int curr, int lo, int mid, int hi) { int arr[n]; for (int i = lo; i <= mid; i++) { if (dir[i] == NA) arr[i] = dir[curr]; else arr[i] = dir[i]; } for (int i = mid+1; i <= hi; i++) { if (arr[i] == NA) arr[i] = 1-dir[curr]; } return tryCombination(arr); } void exploreCave(int N) { int S[N]; int D[N]; dir = vi(N, NA); // Dir to close door n = N; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { S[j] = dir[j]; if (S[j] == NA) S[j] = DOWN; } int tmp = tryCombination(S); if (tmp == i) { dir[i] = DOWN; } else dir[i] = UP; int lo = 0, hi = N-1, mid; while (lo < hi) { mid = (lo+hi)/2; bool isDownI = check(i, lo, mid, hi) == i; if (isDownI) { hi = mid; } else lo = mid + 1; } D[lo] = i+1; } for (int i = 0; i < N; i++) S[i] = dir[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...