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