# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1055620 | LeaRouse | Split the Attractions (IOI19_split) | C++14 | 0 ms | 0 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 <bits/stdc++.h>
#include "split.h"
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const int MAX=1e5+5;
const int MOD=1e8+7;
int R[MAX];
int A[MAX];
int B[MAX];
map<string,int>m;
vector<int>v;
bool vis[MAX];
int cont=0;
void dfs(int u){
A[cont]=u;
cont++;
vis[u]=true;
for(auto it:v[u]){
if(vis[it]) continue;
dfs(it);
}
}
vector<int> find_split(int N, int a, int b, int c, vector<int> p, vector<int> q) {
int m=p.size();
for(int i=0;i<m;i++){
v[p[i]].push_back(q[i]);
v[q[i]].push_back(p[i]);
B[p[i]]++;
B[q[i]]++;
}
bool awa=false;
for(int i=0;i<N;i++){
if(B[i]==1){
dfs(i);
awa=true;
break;
}
}
if(!awa) dfs(0);
vector<int>ans(n);
for(int i=0;i<a;i++){
ans[A[i]]=1;
}
for(int i=a;i<a+b;i++){
ans[A[i]]=2;
}
for(int i=a+b;i<a+b+c;i++){
ans[A[i]]=3;
}
return ans;
}