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 pb push_back
/*
subtask 1, line
easy, split by sections
*/
/*
subtask 2
*/
const int maxn = 1e5 + 5;
vector<int> graph[maxn];
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int> ans(n);
int m = p.size();
int cur = -1;
for(int i =0; i<m ;i++){
//cout << p[i] <<", "<<q[i]<<endl;
graph[p[i]].pb(q[i]);
graph[q[i]].pb(p[i]);
}
for(int i =0; i<n; i++){
if(graph[i].size() == 1)
{
cur = i;
break;
}
}
vector<bool> vis(n);
while(c > 0){
//cout <<cur<<endl;
if(a > 0){
a--;
ans[cur] = 1;
}else if(b > 0){
b--;
ans[cur] = 2;
}
else{
c--;
ans[cur] = 3;
}
vis[cur] =true;
for(int adj : graph[cur])
{
if(!vis[adj])
{
cur = adj;
break;
}
}
}
return ans;
}
/************/
# | 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... |