제출 #391892

#제출 시각아이디문제언어결과실행 시간메모리
391892Pichon5Split the Attractions (IOI19_split)C++17
0 / 100
792 ms1048580 KiB
#include "split.h" #include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair using namespace std; vi res; vector<vi>G; vector<pair<int,int> >v; bool ok=false; vi peso; int n; void dfs1(int nodo, int p){//esto es para flutfitear el mas bajito if(v[0].F==0)return; res[nodo]=v[0].S; v[0].F--; for(auto it : G[nodo]){ if(it==p)continue; dfs1(it,nodo); } } void dfs2(int nodo, int p){ if(v[1].F==0)return; res[nodo]=v[1].S; v[1].F--; for(auto it : G[nodo]){ if(it==p)continue; dfs2(it,nodo); } } void check(int nodo, int p){ for(auto it : G[nodo]){ if(it==p)continue; check(it,nodo); peso[nodo]+=peso[it]; if(peso[it]>=v[0].F && n-v[0].F>=v[1].F && ok==0){ ok=1; dfs1(it,nodo); dfs2(nodo,it); } if(peso[it]>=v[1].F && n-v[0].F>=v[2].F && ok==0){ ok=1; dfs1(nodo,it); dfs2(it,nodo); } } peso[nodo]++; } vector<int> find_split(int N, int a, int b, int c, vector<int> p, vector<int> q) { int m=p.size(); n=N; G.assign(n,vi()); peso.resize(n+1,0); for(int i=0;i<m;i++){ G[p[i]].pb(q[i]); G[q[i]].pb(p[i]); } v.pb({a,1});v.pb({b,2});v.pb({c,3}); sort(v.begin(),v.end()); res.assign(n,v[2].S); check(0,0); if(!ok)res.assign(n,0); return res; } /* 10 9 6 2 2 0 1 0 2 0 3 3 4 4 8 8 9 4 7 3 5 3 6 */
#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...