# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121298 | PagodePaiva | Cave (IOI13_cave) | C++17 | 148 ms | 772 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>
#include "cave.h"
using namespace std;
const int N = 5000;
int c[N];
int d[N];
int query(int ask[]){
/*for(int i = 0;i < 4;i++){
cout << ask[i] << ' ';
}
cout << '\n';*/
int d = tryCombination(ask);
return d;
}
void exploreCave(int n) {
int ask[n];
for(int i = 0;i < n;i++){
ask[i] = 0;
}
int t;
vector <int> v;
for(int i = 0;i <n;i++){
v.push_back(i);
}
t = query(ask);
for(int i = 0;i < n;i++){
int l = 0, r = v.size()-1;
while(l < r){
int mid = (l+r)/2;
for(int j = l;j <= mid;j++){
ask[v[j]] ^= 1;
}
int tt = query(ask);
if(t == i and tt == i){
l = mid+1;
}
else if(t == i and tt != i){
r = mid;
}
else if(t != i and tt != i){
l = mid+1;
}
else{
r = mid;
}
t = tt;
}
c[i] = v[l];
if(t != i) d[i] = ask[v[l]];
else{
ask[v[l]] ^= 1;
d[i] = ask[v[l]];
t = query(ask);
}
vector <int> vv;
for(int j = 0;j < v.size();j++){
if(v[l] == v[j]) continue;
vv.push_back(v[j]);
}
v = vv;
}
int res1[n], res2[n];
for(int i = 0;i < n;i++){
res1[c[i]] = i;
res2[c[i]] = d[i];
}
answer(res2, res1);
return;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |