제출 #426879

#제출 시각아이디문제언어결과실행 시간메모리
426879PbezzSplit the Attractions (IOI19_split)C++14
7 / 100
90 ms24908 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back typedef pair<ll,ll> pii; const ll MAXN = 2e5+5; const ll INF = 1e9+7; vector<vector<ll>>adj(MAXN); int order[MAXN]; void dfs(ll node, ll p, ll ind){ order[ind]=node; for(auto u:adj[node]){ if(u==p)continue; dfs(u,node,ind+1); } } vector<int> find_split(int n,int a,int b,int c,vector<int>p,vector<int> q) { int i,m=p.size(); vector<int> res(n); int deg[n+1]; for(i=0;i<m;i++){ deg[i]=0; } for(i=0;i<m;i++){ deg[p[i]]++; deg[q[i]]++; } bool ok=false; for(i=0;i<n;i++){ if(deg[i]==1){//cout<<"hihi"; ok=true; break; } } for(i=1;i<m;i++){ adj[p[i]].pb(q[i]); adj[q[i]].pb(p[i]); } if(ok==true){i=0; adj[p[i]].pb(q[i]); adj[q[i]].pb(p[i]); }else{ deg[p[0]]--; deg[q[0]]--; } for(i=0;i<n;i++){ if(deg[i]==1){ ok=true; break; } } dfs(i,-1,0); for(i=0;i<a;i++)res[order[i]]=1; for(i=a;i<a+b;i++)res[order[i]]=2; for(i=a+b;i<n;i++)res[order[i]]=3; return res; }
#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...