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;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab (int x ) { return (x>0?x:-x); }
int n ;
int door[5005] , comb[5005];
void rev(int l , int r ){
for(;l<=r;l++){
if( door[l]==-1)comb[l]=!comb[l];
}
}
// void answer(int S[],int D[]){
// for(int i = 0 ; i < n ; i++ )cout << S[i];
// cout<<endl;
// for(int i = 0 ; i < n ; i++ )cout<<D[i];
// cout << endl ;
// }
// int tryCombination(int S[]){
// cout << "try comb"<<endl;
// for(int i = 0 ; i < n ; i++ )cout << S[i];
// cout<<endl;
// int ans;
// cin >> ans;
// return ans ;
// }
void findDoor(int i ){
int l = 0 , r = n-1 ;
int start = tryCombination(comb);
if( start != i )rev(0,n-1);
while ( l < r ){
int mid = (l+r)/2 ;
rev(l,mid);
int reply = tryCombination(comb);
rev(l,mid);
if( reply != i ){
r = mid ;
}else {
l = mid+1;
}
// start = reply ;
}
// cout << "door "<<l<<" " << i << endl;
door[l]=i ;
comb[l]=!comb[l];
}
void exploreCave(int N){
n = N ;
memset(door,-1,sizeof door);
for(int i = 0 ; i < n ; i++ )findDoor(i);
int ans[N];
// for(int i = 0 ; i < n ; i++ )ans[door[i]]=i;
answer(comb,door);
}
// int main(){
// cin >> n;
// exploreCave(n);
// }
Compilation message (stderr)
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:70:6: warning: unused variable 'ans' [-Wunused-variable]
int ans[N];
^~~
# | 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... |