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] = 1 - base[ii];
}
// 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;
}
int cnt = 0 , idx;
REP(i , 0 , n) if(use[i] == 0 && cnt <= can) cnt ++ , idx = i;
assert(can < n);
use[idx] = 1;
ans[idx] = pre > i ? base[idx] : 1 - base[idx];
mah[idx] = i;
base[idx] = ans[idx];
// break;
// if(i == 3) break;
}
answer(ans , mah);
}
Compilation message (stderr)
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:59:12: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
use[idx] = 1;
~~~~~~~~~^~~
# | 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... |