Submission #426913

#TimeUsernameProblemLanguageResultExecution timeMemory
426913PbezzSplit the Attractions (IOI19_split)C++14
11 / 100
122 ms16964 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],cur=1,B; bool visited[MAXN]; void dfs(ll node){//cur esta a contar com este visited[node]=true; order[node]=2; for(auto u:adj[node]){ if(visited[u])continue; if(cur+1<=B){ cur++; dfs(u); } } } vector<int> find_split(int n,int a,int b,int c,vector<int>p,vector<int> q) { int i,m=p.size(); B=b; vector<int> res(n); for(i=0;i<n;i++)order[i]=0; for(i=0;i<m;i++){ adj[p[i]].pb(q[i]); adj[q[i]].pb(p[i]); } dfs(0); bool done = false; for(i=0;i<n;i++){ if(order[i]==2){ res[i]=2; }else if(done==false){ res[i]=1; done=true; }else{ res[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...