제출 #320383

#제출 시각아이디문제언어결과실행 시간메모리
320383egod1537동굴 (IOI13_cave)C++14
0 / 100
88 ms484 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; bitset<5001> vit; void exploreCave(int n) { int* arr = new int[n]; int* cnt = new int[n]; function<void(int, int)> rev = [&](int s, int e) -> void { for (int i = s; i <= e; i++) { if (vit[i]) continue; arr[i] = (arr[i] == 1) ? 0 : 1; } }; for (int i = 0; i < n; i++) { int pos = 0; int k = tryCombination(arr); if (k == -1) continue; int lo = 0, hi = n - 1; while (lo <= hi) { int mid = (lo + hi) / 2; rev(lo, mid); int w = tryCombination(arr); //이미 문이 열려있음 if (k > i) { if (w == i) hi = mid - 1; else lo = mid + 1; } //이미 문이 닫혀있을 때 else { if (w > i) hi = mid - 1; else lo = mid + 1; } rev(lo, mid); } if (k <= i) arr[pos] = (arr[pos] == 1) ? 0 : 1; cnt[i] = pos; vit[pos] = true; } answer(arr, cnt); }
#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...