# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
804614 | faruk | Split the Attractions (IOI19_split) | C++17 | 81 ms | 16064 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "split.h"
#include <bits/stdc++.h>
#define mp make_pair
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
vector<vector<int> > graph;
int n;
vector<bool> visited;
vector<int> vec;
void dfs(int curr) {
visited[curr] = true;
vec.push_back(curr);
for (int nei : graph[curr])
if (!visited[nei])
dfs(nei);
}
vector<int> get_order() {
int s = 0;
visited.resize(n);
for (int i = 0; i < n; i++)
if (graph[i].size() == 1)
s = i;
dfs(s);
return vec;
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int> res(n);
::n = n;
graph.resize(n);
for (int i = 0; i < p.size(); i++)
{
graph[p[i]].push_back(q[i]);
graph[q[i]].push_back(p[i]);
}
vector<int> order = get_order();
for (int i = 0; i < a; i++)
res[order[i]] = 1;
for (int i = a; i < a+b; i++)
res[order[i]] = 2;
for (int i = a+b; i < a+b+c; i++)
res[order[i]] = 3;
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |