제출 #1203926

#제출 시각아이디문제언어결과실행 시간메모리
1203926andrejikus동굴 (IOI13_cave)C++20
0 / 100
166 ms544 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; typedef long long ll; void DBG() { cerr << "]" << endl; } template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); } #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) const int N = 5003; int s[N], ans[N], orig[N], d[N]; int tryCombination(int S[]); void answer(int S[], int D[]); void exploreCave(int n) { for (int i = 0; i < n; i++) d[i] = -1; auto ok = [&](int l, int r, int i) { for (int k = l; k <= r; k++) { if (d[k] != -1) continue; s[k] = orig[k]^1; } int x = (tryCombination(s) != i); for (int k = l; k <= r; k++) { if (d[k] != -1) continue; s[k] = orig[k]; } return (x > 0); }; for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) { orig[i] = ans[i]; s[i] = ans[i]; } int x = tryCombination(orig); if (x != i) { for (int k = 0; k < n; k++) { if (d[k] != -1) continue; orig[k] = orig[k]^1; } } int low = 0, high = n-1; while (low < high) { int mid = (low + high) / 2; if (ok(low, mid, i)) high = mid; else low = mid+1; } d[low] = i; ans[low] = 0; x = tryCombination(ans); if (x == i) ans[low] = 1; } answer(ans, 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...