Submission #428310

#TimeUsernameProblemLanguageResultExecution timeMemory
428310HazemSplit the Attractions (IOI19_split)C++14
18 / 100
102 ms13656 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; const int N = 2e5+10; vector<int>adj[N],ans; int n,m; bool vis[N]; void dfs(int i,int c,int &cnt){ if(vis[i]||cnt<=0) return ; cnt--; vis[i] = 1;ans[i] = c; for(auto x:adj[i]) if(!vis[x])dfs(x,c,cnt); } vector<int> find_split(int n1, int a, int b, int c, vector<int> p, vector<int> q) { n = n1;m = p.size(); ans = vector<int>(n,0); for(int i=0;i<m;i++){ adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]); } int st = 0; for(int i=0;i<n;i++) if(adj[i].size()==1) st = i; dfs(st,1,a); for(int i=0;i<n;i++) if(!vis[i]){ dfs(i,2,b); break; } for(int i=0;i<n;i++) if(!ans[i])ans[i] = 3; return ans; }
#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...