제출 #228973

#제출 시각아이디문제언어결과실행 시간메모리
228973tushar_2658동굴 (IOI13_cave)C++14
51 / 100
918 ms640 KiB
#include "cave.h" #include "bits/stdc++.h" using namespace std; const int maxn = 5005; int n; vector<pair<int, int>> v; bool can(int l, int r, int f, int pos){ if(l > r)return 0; int s1[maxn]; for(int i = 0; i < n; ++i){ s1[i] = f; } for(int i = l; i <= r; ++i){ s1[i] ^= 1; } for(auto i : v){ s1[i.first] = i.second; } int x = tryCombination(s1); if(x > pos or x == -1)return 1; else return 0; } void exploreCave(int N) { n = N; int s[N], D[N]; memset(s, 0, sizeof s); for(int i = 0; i < N; ++i){ int l = 0, r = N - 1, ans = 0; int bit = 0; if(can(0, N - 1, 1, i)){} else { bit = 1; } while(l <= r){ int mid = (l + r) >> 1; if(can(mid, r, bit ^ 1, i)){ ans = mid; l = mid + 1; }else { r = mid - 1; } } v.push_back(make_pair(ans, bit)); } for(int i = 0; i < N; ++i){ s[v[i].first] = v[i].second; } for(int i = 0; i < n; ++i){ s[i] ^= 1; D[i] = tryCombination(s); s[i] ^= 1; } 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...