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 <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k) for(int i = j ; i < k ; ++i)
#define RREP(i,j,k) for(int i = j ; i >=k ; --i)
#define A first
#define B second
#define mp make_pair
#define pb emplace_back
#define PII pair<int , int>
#define MEM(i,j) memset(i , j , sizeof i)
#define ALL(i) i.begin() , i.end()
#define DBGG(i,j) cout << i << " " << j << endl
#define DB4(i,j,k,l) cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#include "cave.h"
#define MAX
#define INF 0x3f3f3f3f
int nn , mah[5000] , ans[5000] , base[5000] , val[5000] , use[5050] , pre;
int SSS = 0;
int query(int x[]){
SSS ++;
assert(SSS <= 70000);
int ans = tryCombination(x);
if(ans == -1) return nn + 1;
else return ans;
}
void exploreCave(int n){
nn = n;
REP(i , 0 , n){
pre = query(base);
// REP(i , 0 , n) cout << base[i] << " "; cout << endl;
// DBGG("pre = " , pre);
int can = -1;
RREP(j , 13 , 0){
int to = can + (1 << j) , cnt = 0;
REP(ii , 0 , n) val[ii] = base[ii];
REP(ii , 0 , n) if(cnt < to && use[ii] == 0){
cnt ++;
val[ii] = base[ii] ^ 1;
}
// if(cnt == to){
// cout << "now to = " << to << " ->";
// REP(ii , 0 , n) cout << val[ii] << " "; cout << endl;
// DBGG("get = " , query(val));
// }
if(cnt == to && (query(val) > i) == (pre > i)) can = to;
}
while(use[can] == 1) can ++;
// DBGG("can = " , can);
use[can] = 1;
ans[can] = pre > i ? base[can] : 1 - base[can];
mah[can] = i;
base[can] = ans[can];
// REP(i , 0 , n) cout << base[i] << " "; cout << endl;
// if(i == 1)
// break;
}
answer(ans , mah);
}
# | 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... |