# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
718147 | mseebacher | Split the Attractions (IOI19_split) | C++17 | 76 ms | 12584 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;
#define MAX_N (int) 1e5+5
vector<int> ad[MAX_N];
vector<int> res;
vector<bool> vis(MAX_N);
int cnt;
void dfs(int x,char side){
if(vis[x] || cnt == 0) return;
vis[x] = 1;
if(side == 'b'){
res[x] = 2;
}else{
res[x] = 3;
}
cnt--;
for(auto s: ad[x]){
dfs(s,side);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
for(int i = 0;i<(int)p.size();i++){
ad[p[i]].push_back(q[i]);
ad[q[i]].push_back(p[i]);
}
res.assign(n,0);
if(p.size() < n-1 || b >= n-1 || c>=n-1) return res;
cnt = min(b,c);
if(b < c){
res.assign(n,3);
dfs(0,'b');
for(int i = 0;i<n;i++){
if(res[i] == 3){
res[i] = 1;
break;
}
}
}else{
res.assign(n,2);
dfs(0,'c');
for(int i = 0;i<n;i++){
if(res[i] == 2){
res[i] = 1;
break;
}
}
}
if(cnt != 0) res.assign(n,0);
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... |