# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
571939 | SlavicG | Cave (IOI13_cave) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
/*
int tryCombination(vector<int> s) {
for(auto x: s) cout << x << " ";
cout << "\n";
int f; cin >> f;
return f;
}
void answer(vector<int> s, vector<int> d) {
for(auto x: s) cout << x << " ";
cout << "\n";
for(auto x: d) cout << x << " ";
cout << "\n";
}
*/
void exploreCave(int n) {
vector<int> d(n, -1);
vector<int> s(n, -1);
int lst = -1;
for(int i = 0; i < n; ++i) {
vector<int> tmp = s;
forn(j, n) if(s[j] == -1) tmp[j] = 0;
int x = tryCombination(tmp);
int need = 0;
if(x == -1) x = n;
if(x <= i) {
need = 1;
forn(j, n) if(s[j] == -1) tmp[j] = 1;
}
d[i] = need;
int l = 0, r = n - 1, pos = -1;
while(l <= r) {
int mid = l + r >> 1;
for(int j = mid; j < n; ++j) {
if(s[j] == -1) {
tmp[j] = !need;
}
}
x = tryCombination(tmp);
if(x <= i) {
r = mid - 1;
} else {
pos = mid;
l = mid + 1;
}
}
s[pos] = i;
}
answer(s, d);
}
/*
void solve() {
int n; cin >> n;
exploreCave(n);
}
int32_t main() {
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
while(t--) {
solve();
}
}
*/