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 ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 2e5+5;
const ll INF = 1e9+7;
vector<vector<ll>>adj(MAXN);
int order[MAXN],cur=1,B;
bool visited[MAXN];
void dfs(ll node){//cur esta a contar com este
visited[node]=true;
order[node]=2;
for(auto u:adj[node]){
if(visited[u])continue;
if(cur+1<=B){
cur++;
dfs(u);
}
}
}
vector<int> find_split(int n,int a,int b,int c,vector<int>p,vector<int> q) {
int i,m=p.size(); B=b;
vector<int> res(n);
for(i=0;i<n;i++)order[i]=0;
for(i=0;i<m;i++){
adj[p[i]].pb(q[i]);
adj[q[i]].pb(p[i]);
}
dfs(0);
bool done = false;
for(i=0;i<n;i++){
if(order[i]==2){
res[i]=2;
}else if(done==false){
res[i]=1;
done=true;
}else{
res[i]=3;
}
}
return res;
}
# | 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... |