Submission #432620

#TimeUsernameProblemLanguageResultExecution timeMemory
432620LouayFarahSplit the Attractions (IOI19_split)C++14
18 / 100
122 ms17220 KiB
#include "bits/stdc++.h" #include "split.h" using namespace std; #define ll long long #define pb push_back void dfs(vector<int> adj[], vector<bool> &visited, int u, vector<int> &res) { res.pb(u); visited[u] = true; for(auto v: adj[u]) { if(!visited[v]) { dfs(adj, visited, v, res); } } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int>q) { vector<int> adj[n]; int m = (int)p.size(); for(int i = 0; i<m; i++) { adj[p[i]].pb(q[i]); adj[q[i]].pb(p[i]); } vector<int> res; vector<bool> visited(n, false); int beg = 0; for(int i = 0; i<n; i++) { if((int)adj[i].size()==1) { beg = i; break; } } dfs(adj, visited, beg, res); vector<int> r(n, 0); int i = 0; int counter = 0; while(counter<a) { r[res[i]] = 1; i++, counter++; } counter = 0; while(counter<b) { r[res[i]] = 2; i++, counter++; } counter = 0; while(counter<c) { r[res[i]] = 3; i++, counter++; } return r; }
#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...