# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164458 | 2019-11-20T17:34:53 Z | Lawliet | ICC (CEOI16_icc) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> //#include "icc.h" using namespace std; typedef pair<int,int> pii; const int MAXN = 60; int N; int other[MAXN]; bool marc[MAXN]; vector< int > adj[MAXN]; void DFS(int cur) { marc[ cur ] = true; for(int i = 0 ; i < adj[cur].size() ; i++) { int viz = adj[cur][i]; if( marc[viz] ) continue; DFS( viz ); } } void run(int n) { N = n; for(int k = 1 ; k < N ; k++) { bool find = false; int ansA = 0; int ansB = 0; for(int i = 1 ; i <= n && !find ; i++) { memset( marc , false , sizeof( marc ) ); DFS( i ); int cur[] = { i }; int p = 0; for(int j = 1 ; j <= n ; j++) if( !marc[j] ) other[ p++ ] = j; if( query( 1 , p , cur , other ) == 1 ) { ansA = i; for(int j = 0 ; j < p && !find ; j++) { int V[] = { other[j] }; if( query( 1 , 1 , cur , V ) == 1 ) { ansB = other[j]; find = true; } } } } adj[ ansB ].push_back( ansA ); adj[ ansA ].push_back( ansB ); setRoad( ansA , ansB ); } }