이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include "cave.h"
# include <iostream>
using namespace std;
int n, a[5000], b[5000];
int A[5000], B[5000], counter;
/*
bool answer( int S[], int D[] )
{
bool T = true;
for ( int i = 0; i < n; i ++ ){
if( S[i] != a[i] )
T = false;
}
for ( int i = 0; i < n; i ++ ){
if( D[i] != b[i] )
T = false;
}
cout << ( T? "YES":"NO" ) << endl;
cout << "counter :" << counter << endl;
return T;
}
int tryCombination( int S[] )
{
counter ++;
for ( int i = 0; i < n; i ++ ){
if ( S[ b[i] ] != a[ b[i] ] )
return i;
}
return -1;
}
*/
void exploreCave( int N )
{
int S[5000] = {};
fill( B, B + n, 5000 );
for ( int i = 0; i < n; i ++ ){
for ( int j = 0; j < n; j ++ )
S[j] = 0;
for ( int j = 0; j < i; j ++ )
S[ B[j] ] = A[ B[j] ];
int cs = tryCombination( S );
/*
for ( int j = 0; j < n; j ++ )
cout << S[j] << ' ';
cout << cs << endl;
*/
int open = 0;
if( cs == i )
open = 1;
int l = 0, r = n - 1;
while( r > l ){
int m = ( l + r ) >> 1;
for ( int j = 0; j < n; j ++ )
S[j] = open;
for ( int j = l; j <= m; j ++ )
S[j] = 1 - open;
for ( int j = 0; j < i; j ++ )
S[ B[j] ] = A[ B[j] ];
int cs = tryCombination( S );
if( cs == i )
r = m;
else
l = m + 1;
}
B[i] = l;
A[ B[i] ] = open;
//cout << i << ' ' << B[i] << ' ' << A[ B[i] ] << endl;
}
answer( A, B );
}
/*
int main()
{
cin >> n;
for ( int i = 0; i < n; i ++ )
cin >> a[i];
for ( int i = 0; i < n; i ++ )
cin >> b[i];
exploreCave( n );
return 0;
}
*/
# | 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... |