이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std ;
const int Ne = 5005 ;
#define go tryCombination
int a[Ne] , b[Ne] , c[Ne] , vis[Ne] ;
int n ;
vector <int> vec ;
void rec ( vector <int> ind , int cur ){
if ( ind.size() == 1 ){
a[ind[0]] = 1 ;
int x = go(a) ;
if ( (x != cur && b[cur] == 1) || (x == cur && b[cur] == 0) )
c[cur] = ind[0] , vis[ind[0]] = cur , a[ind[0]] = b[cur] ;
return ;
}
int mid = ind.size() / 2 ;
for ( int i = 0 ; i < mid ; i ++ ) a[ind[i]] = 1 ;
int x = go(a) ;
for ( int i = 0 ; i < mid ; i ++ ) a[ind[i]] = 0 ;
vector <int> v ;
if ( (x != cur && b[cur] == 1) || (x == cur && b[cur] == 0) )
for ( int i = 0 ; i < mid ; i ++ ) v.push_back(ind[i]) ;
else for ( int i = mid ; i < (int)ind.size() ; i ++ ) v.push_back(ind[i]) ;
rec( v , cur ) ;
}
void exploreCave(int N) {
n = N ;
for ( int i = 0 ; i < n ; i ++ ) vis[i] = -1 ;
for ( int i = 0 ; i < n ; i ++ ) vec.push_back(i) ;
int x = go(a) ;
if ( x == 0 ) b[0] = 1 ;
rec (vec , 0 ) ;
for ( int i = 1 ; i < n ; i ++ ){
vec.clear() ;
for ( int j = 0 ; j < n ; j ++ ){
if ( vis[j] == -1 ) vec.push_back(j) , a[j] = 0 ;
else a[j] = b[vis[j]] ;
}
x = go(a) ;
if ( x == i ) b[i] = 1 ;
rec(vec,i) ;
}
for ( int i = 0 ; i < n ; i ++ ) c[i] = b[vis[i]] ;
answer ( c , vis ) ;
}
# | 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... |