# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1059947 | Unforgettablepl | Split the Attractions (IOI19_split) | C++17 | 50 ms | 13504 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>
using namespace std;
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int> res(n);
vector<bool> visited(n);
vector<vector<int>> adj(n);
for(int i=0;i<p.size();i++)adj[p[i]].emplace_back(q[i]);
for(int i=0;i<p.size();i++)adj[q[i]].emplace_back(p[i]);
int chosen = 0;
int curr = 0;
int tar = 0;
function<void(int)> dfs = [&](int x) {
if(visited[x])return;
visited[x]=true;
res[x]=curr;
if(++chosen==tar)return;
for(int&i:adj[x]) {
dfs(i);
if(chosen==tar)return;
}
};
curr = 1;
tar = a;
for(int i=0;i<n;i++)if(!visited[i]){
dfs(i);
break;
}
curr = 2;
tar = a+b;
for(int i=0;i<n;i++)if(!visited[i]){
dfs(i);
break;
}
curr = 3;
tar = a+b+c;
for(int i=0;i<n;i++)if(!visited[i]){
dfs(i);
break;
}
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... |