이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void SW(int in[],int dn[],int ps){
for(int i=0;i<ps;i++){
if(dn[i]==0){
in[i]=1-in[i];
}
}
}
/*int tryCombination(int in[]){
for(int i=0;i<sizeof in;i++){
cout<<in[i]<<' ';
}
cout<<endl;
int vl;cin>>vl;
return vl;
}*/
void exploreCave(int N){
int in[N],ns[N],dn[N];
for(int i=0;i<N;i++)in[i]=ns[i]=dn[i]=0;
for(int i=0;i<N;i++){
int cur=tryCombination(in);
if(cur==-1)cur=N;
if(cur>i){
int l=1,r=N,ans=N;
while(l<=r){
int m=(l+r)/2;
SW(in,dn,m);
int vl=tryCombination(in);
if(vl==-1)vl=N;
if(vl<=i){
ans=m;
r=m-1;
}else{
l=m+1;
}
SW(in,dn,m);
}
ans--;
dn[ans]=1;
ns[i]=ans;
//cout<<ans<<endl;
}else{
int l=1,r=N,ans=N;
while(l<=r){
int m=(l+r)/2;
SW(in,dn,m);
int vl=tryCombination(in);
if(vl==-1)vl=N;
if(vl>i){
ans=m;
r=m-1;
}else{
l=m+1;
}
SW(in,dn,m);
}
ans--;
dn[ans]=1;
ns[i]=ans;
in[ans]=1;
//cout<<ans<<endl;
}
}
/*for(int i=0;i<N;i++){
cout<<in[i]<<' ';
}
cout<<endl;
for(int i=0;i<N;i++){
cout<<ns[i]<<' ';
}
cout<<endl;*/
answer(in,ns);
}
/*
int main(){
exploreCave(4);
}
*/
# | 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... |