Submission #919758

#TimeUsernameProblemLanguageResultExecution timeMemory
919758CutebolCave (IOI13_cave)C++17
100 / 100
221 ms1024 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...