# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1063712 | aaaaaarroz | Split the Attractions (IOI19_split) | C++17 | 0 ms | 392 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<vector<int>>graph(n,vector<int>());
for(int i=0;i<q.size();i++){
graph[p[i]].push_back(q[i]);
graph[q[i]].push_back(p[i]);
}
int pivot=0;
vector<int>nodes;
queue<int>cola;
cola.push(pivot);
vector<bool>v(n,false);
v[pivot]=true;
nodes.push_back(pivot);
while(!cola.empty()&&nodes.size()<max(b,c)){
int nodo=cola.front();
cola.pop();
nodes.push_back(nodo);
for(int vecino:graph[nodo]){
v[vecino]=true;
cola.push(vecino);
}
}
vector<int>ans(n,0);
if(b>c){
for(int nodo:nodes){
ans[nodo]=2;
}
for(int i=0;i<n;i++){
if(ans[i]==0){
ans[i]=3;
}
}
for(int i=0;i<n;i++){
if(ans[i]==3){
ans[i]=1;
break;
}
}
}
else{
for(int nodo:nodes){
ans[nodo]=3;
}
for(int i=0;i<n;i++){
if(ans[i]==0){
ans[i]=2;
}
}
for(int i=0;i<n;i++){
if(ans[i]==2){
ans[i]=1;
break;
}
}
}
return ans;
}
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... |