제출 #962785

#제출 시각아이디문제언어결과실행 시간메모리
962785NValchanov동굴 (IOI13_cave)C++17
21 / 100
301 ms604 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; typedef long long ll; const ll MAXN = 100; int door[MAXN]; int pos[MAXN]; ll n; void flip_pos(ll to) { for(int i = 0; i <= to; i++) { if(door[i] == -1) pos[i] ^= 1; } } void init_switches() { for(int i = 0; i < n; i++) { door[i] = -1; pos[i] = 0; } } bool check(ll k, ll i) { flip_pos(k); ll cur = tryCombination(pos); flip_pos(k); return cur == i; } void exploreCave(int N) { n = N; init_switches(); for(int i = 0; i < n; i++) { ll cur = tryCombination(pos); if(cur == i) flip_pos(n - 1); ll left = 0; ll right = n - 1; ll ans = -1; ll mid; while(left <= right) { mid = (left + right) / 2; if(check(mid, i)) { right = mid - 1; ans = mid; } else left = mid + 1; } door[ans] = i; } answer(pos, door); }
#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...