Submission #546868

#TimeUsernameProblemLanguageResultExecution timeMemory
546868uroskConnecting Supertrees (IOI20_supertrees)C++14
0 / 100
0 ms212 KiB
#include "supertrees.h" #include "bits/stdc++.h" #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define ld double #define ll long long #define ull unsigned long long #define llinf 100000000000000000LL // 10^17 #define iinf 2000000000 // 2*10^9 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pii pair<int,int> #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) ((ll)(a.size())) #define all(a) a.begin(),a.end() #define rall(a) a.begin(),a.end(),greater<int>() #define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());} #define pi 3.14159265358979323846 #define here cerr<<"=============================================================================\n" #define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;} #define ceri2(a,l,r,n,m) {for(ll i = l;i<=r;i++){for(ll j = n;j<=m;j++) cerr<<a[i][j]<< " ";cerr<<endl;}} #define yes cout<<"YES"<<endl #define no cout<<"NO"<<endl #define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); using namespace std; #define maxn 1005 ll dsu[maxn]; ll root(ll x){ while(x!=dsu[x]){ dsu[x] = dsu[dsu[x]]; x = dsu[x]; } return x; } void upd(ll x,ll y){dsu[root(x)] = root(y);} bool get(ll x,ll y){return root(x)==root(y);} vector<ll> v[maxn]; vector<std::vector<int>> answer; void upd2(ll x,ll y){ answer[x][y] = 1; answer[y][x] = 1; } int construct(std::vector<std::vector<int>> p) { int n = p.size(); for(ll i = 0;i<n;i++){ vector<int> w(n); answer.pb(w); } iota(dsu,dsu+n,0); for(ll i = 0;i<n;i++){ for(ll j = 0;j<n;j++){ if(p[i][j]==3) return 0; } for(ll j = 0;j<n;j++){ if(p[i][j]==1) upd(i,j); } } vector<vector<ll> >w; for(ll i = 0;i<n;i++) v[root(i)].pb(i); for(ll i = 0;i<n;i++) if(sz(v[i])) w.pb(v[i]); for(ll i = 0;i<sz(w);i++){ for(ll j = 0;j<sz(w[i])-1;j++){ answer[w[i][j]][w[i][j+1]] = 1; answer[w[i][j+1]][w[i][j]] = 1; } } for(ll i = 0;i<sz(w);i++){ for(ll j = 0;j<sz(w);j++){ if(p[root(w[i].back())][root(w[j].back())]>0){ upd2(root(w[i].back()),root(w[j].back())); upd(root(w[i].back()),root(w[j].back())); } } } build(answer); return 1; } /* 4 1 1 2 2 1 1 2 2 2 2 1 2 2 2 2 1 */
#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...