Submission #259354

#TimeUsernameProblemLanguageResultExecution timeMemory
259354youssefbou62ICC (CEOI16_icc)C++14
0 / 100
1 ms384 KiB
#include<bits/stdc++.h> #include "icc.h" using namespace std; #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define allarr(a) a , a + n #define ll long long #define ull unsigned long long #define pb push_back #define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL) #define sz(x) (int)x.size() typedef pair<int, int> pi; typedef pair<ll,ll> pll; typedef pair<int,pi> trp ; typedef vector<pi> vpi; typedef vector<pll> vpll ; // int ab (int x ) { return (x>0?x:-x); } //typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int MAXN = 105 ; int n ; int par[MAXN]; vector<int> groups , inG[MAXN]; void init(int N){ for(int i = 1 ; i <= N ; i++ )par[i] = i , groups.pb(i),inG[i].pb(i); } int fs(int u){ if( par[u] == u )return u; return par[u] = fs(par[u]) ; } void us(int u,int v){ u = fs(u) ; v = fs(v) ; if( u == v )return ; par[u] = v ; for(int x : inG[u]) inG[v].pb(x) ; } // int query(int size_a, int size_b, int a[], int b[]){ // cout << "QUERY *********"<<endl; // cout << size_a << endl; // for(int i = 0 ; i < size_a ; i++ )cout << a[i] << " " ;cout << endl; // cout << size_b << endl; // for(int i = 0 ; i < size_b ; i++ )cout << b[i] << " " ;cout << endl; // bool x ; // cin >> x ; // return x ; // } // void setRoad(int a, int b){ // cout << "setRoad "<< a << " " << b << endl; // return ; // } void run(int N){ N = n ; init(n); int a[N],b[N],c[N],d[N]; for(int i = 0 ; i < n - 1 ; i++ ){ int res1 = -1 , res2 = -1 ; int cnt = 0 ; for(int j = 0 ; j < sz(groups) ; j++ ){ int cnt1 = 0 ; for(int x = j + 1 ; x < sz(groups) ; x++ )for(int y : inG[groups[x]] ) b[cnt1] = y , cnt1 ++ ; bool stop = 0; for(int y : inG[groups[j]]){ a[cnt] = y; cnt++; if( query(cnt,cnt1,a,b) ) { res1 = y ; c[0] = y ; int l = 0 , r = cnt1-1 ; while ( l <= r ){ int mid = ( l + r )/ 2 ; int yy = 0 ; for(int x = l ; x <= mid ;x++ ){ d[yy] = b[x] ; yy ++ ; } if(query(1,yy,c,d)) r = mid - 1, res2 = b[mid] ; else l = mid + 1 ; } stop = 1; break ; } } if(stop)break; } setRoad(res1,res2); us(res1,res2); groups.clear(); for(int i = 1 ; i <= n ; i++ ) if( find(all(groups),fs(i))== groups.end() ) groups.pb(fs(i)) ; } } // int main(){ // cin >> n ; // run(n) ; // }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...