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 out( x ) #x << " = " << x << " "
#ifndef LOCAL
#define cerr if(false) cerr
#endif
std::vector< int > nas;
std::vector< int > dor;
int n;
void makeComb( std::vector< int >& v, int l, int r, int fill ){
for( int i=0 ; i < n ; i++ ){
if( nas[i] != -1 ) v[i] = nas[i];
else if( i >= l and i <= r ) v[i] = fill;
else v[i] = ( 1 - fill );
}
}
void f( int l, int r, int x, int sw ){
cerr << out( l ) << out( r ) << out( x ) << out( sw ) << endl;
std::vector< int > currSw( n );
if( l == r ){
nas[l] = sw; // na poz l e switcha e sw
dor[l] = x; // na poz l e vratata e x
return;
}
int m = ( l + r ) >> 1;
makeComb( currSw, l, m, sw );
int q = tryCombination( currSw.data() );
for( auto j : currSw ) cerr << j << " ";
cerr << endl;
cerr << out( q ) << endl;
if( q == x ){ // ne sam go ocelil v ( l, m )
l = m +1;
}else{
r = m;
}
f( l, r, x, sw );
}
void exploreCave( int N ) {
n = N;
std::vector< int > currSw( n );
std::vector< int > order( n );
nas.resize( n );
dor.resize( n );
for( int i=0 ; i < n; i ++ ) nas[i] = -1;
for( int i = 0 ; i < n ; i++ ){ // koj 6te tarsim v momenta
makeComb( currSw, 0, n-1, 0 );
int curr = 0;
int q = tryCombination( currSw.data() );
cerr << out( i ) << std::endl;
for( auto j : currSw ) cerr << j << " ";
cerr << out( q ) << endl;
if( q != i ){// itata e otvorena -> curr = 0;
curr = 0;
}else curr = 1;
cerr << out( curr ) << endl;
f( 0, n-1, i, curr );
}
cerr << " ======== " << endl;
for( auto j : nas ) cerr << j << " ";
cerr << std::endl;
for( auto j : dor ) cerr << j << " ";
cerr << std::endl << std::endl;
answer( nas.data(), dor.data() );
}
# | 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... |