# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
371058 | chubyxdxd | Split the Attractions (IOI19_split) | C++17 | 1 ms | 748 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<vector<int>> G;
vector<int> A;
vector<int> B;
vector<int> C;
int vis[100010];
void dfs(int node,int a,int b,int c){
vis[node]=1;
B.push_back(node);
if(B.size()==b)return;
for(auto i:G[node]){
if(vis[i]==-1){
dfs(i,a,b,c);
if(B.size()==b)return;
}
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int> v {a,b,c};
sort(v.begin(),v.end());
a=v[0];
b=v[1];
c=v[2];
vector<int> ans(n,0);
G.assign(n+5,vector<int>());
for(int i=0;i<p.size();i++){
G[p[i]].push_back(q[i]);
G[q[i]].push_back(p[i]);
}
//cout<<a<<endl;
if(a==1){
memset(vis,-1,sizeof vis);
dfs(0,a,b,c);
for(auto i:B){
ans[i]=2;
}
cout<<a<<endl;
for(int i=0;i<n;i++){
if(ans[i]==0){
if(a>0){
ans[i]=1;
a--;
continue;
}
if(c>0){
ans[i]=3;
c--;
}
}
}
}
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... |