Submission #23375

#TimeUsernameProblemLanguageResultExecution timeMemory
23375rubabredwanICC (CEOI16_icc)C++14
7 / 100
363 ms2140 KiB
/* Bismillahir Rahmanir Rahim */ #include <bits/stdc++.h> #include "icc.h" using namespace std; const int N = 105; int n, par[N], mat[N][N]; set<int>comp; vector<int>nudes[N]; int Find(int at){ return par[at] == at ? at : par[at] = Find(par[at]); } void Union(int a, int b){ int x = Find(a); int y = Find(b); for(auto u : nudes[y]){ nudes[x].push_back(u); } par[y] = x; comp.erase(y); } /* void setRoad(int a, int b){ */ /* if(a) Union(a, b); */ /* if(a) cout << "FOUND " << a << ' ' << b << endl; */ /* int x, y; */ /* cin >> x >> y; */ /* cout << "NEED TO FIND " << x << ' ' << y << endl; */ /* mat[x][y] = 1; */ /* mat[y][x] = 1; */ /* } */ /* int query(int sa, int sb, int a[], int b[]){ */ /* for(int i=0;i<sa;i++){ */ /* for(int j=0;j<sb;j++){ */ /* if(mat[a[i]][b[j]]) return true; */ /* } */ /* } */ /* return false; */ /* } */ int fuk[N], tt; int get(int sa, int sb, int a[], int b[]){ int lo = 0, hi = sb - 1; while(lo < hi){ int mid = (lo + hi) / 2; tt = 0; for(int i=lo;i<=mid;i++) fuk[tt] = b[i], ++tt; if(query(sa, tt, a, fuk)) hi = mid; else lo = mid + 1; } return b[lo]; } int aa[N], bb[N]; int sa, sb; void run(int _n){ n = _n; comp.clear(); for(int i=1;i<=n;i++){ par[i] = i; comp.insert(i); nudes[i].push_back(i); } int road = n - 1; while(road--){ int fnd = 0; for(int i=1;i<=n&&!fnd;i++){ for(int j=1;j<=n&&!fnd;j++){ if(Find(i) == Find(j)) continue; sa = 1, sb = 1; aa[0] = i; bb[0] = j; if(query(sa, sb, aa, bb)){ Union(i, j); setRoad(i, j); fnd = 1; } } } } } /* int main(){ */ /* int ff, x, y; */ /* scanf("%d", &ff); */ /* setRoad(0, 0); */ /* run(ff); */ /* return 0; */ /* } */
#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...