Submission #603481

#TimeUsernameProblemLanguageResultExecution timeMemory
603481SeDunionSplit the Attractions (IOI19_split)C++17
18 / 100
85 ms15696 KiB
#include "split.h" #include<iostream> #include<vector> #include<assert.h> using namespace std; const int N = 2e5 + 123; vector<int>g[N]; int used[N]; int A, B; vector<int>vec; void dfs(int v) { vec.emplace_back(v); used[v] = 1; for (int to : g[v]) if (!used[to]) { dfs(to); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int>ans(n, 3); int m = p.size(); for (int i = 0 ; i < m ; ++ i) { g[p[i]].emplace_back(q[i]); g[q[i]].emplace_back(p[i]); } A = min(min(a, b), c); B = a+b+c - min(min(a, b), c) - max(max(a, b), c); // A <= B <= (C = N - A - B) int root = 0; for (int i = 0 ; i < n ; ++ i) { if ((int)g[i].size() == 1) root = i; } dfs(root); for (int i = 0 ; i < a ; ++ i) ans[vec[i]] = 1; for (int i = 0 ; i < b ; ++ i) ans[vec[i+a]] = 2; //for (int i = 0 ; i < c ; ++ i) ans[vec[i+a+b]] = 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...