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"
#define ll long long
#define fi first
#define se second
using namespace std;
const int N=5000+10;
int aktres[N];
int vis[N];
int ans[N];
int n;
int pom[N];
int bs1(int i){
int pocz=0,kon=n-1;
int sr;
int res=0;
while(pocz<=kon){
sr=(pocz+kon)/2;
for(int j=0;j<n;j++){
if(vis[j]) pom[j]=aktres[j];
else pom[j]=0;
}
for(int j=0;j<=sr;j++) if(!vis[j]) pom[j]=1;
int xd=tryCombination(pom);
if(xd>i||xd==-1){
res=sr;
kon=sr-1;
}else pocz=sr+1;
}
return res;
}
int bs2(int i){
int pocz=0,kon=n-1;
int sr;
int res=0;
while(pocz<=kon){
sr=(pocz+kon)/2;
for(int j=0;j<n;j++){
if(vis[j]) pom[j]=aktres[j];
else pom[j]=1;
}
for(int j=0;j<=sr;j++) if(!vis[j]) pom[j]=0;
int xd=tryCombination(pom);
if(xd>i||xd==-1){
res=sr;
kon=sr-1;
}else pocz=sr+1;
}
return res;
}
void exploreCave(int m){
n=m;
for(int i=0;i<n;i++){
int a=tryCombination(aktres);
bool curr=(a==-1?1:a>i);
curr^=1;
int xd=0;
if(curr) xd=bs1(i);
else xd=bs2(i);
aktres[xd]=curr;
vis[xd]=1;
ans[xd]=i;
}
answer(aktres,ans);
}
# | 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... |