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"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define ff first
#define ss second
const int nax = 1e5 + 4;
int n, m, a, b, c;
vi adj[nax];
int id =2, ot = 3;
int vis[nax];
vi ans;
int cnt = 0;
void dfs(int x)
{
vis[x] = 1;
cnt++;
ans[x] = 2;
for(auto e: adj[x])
{
if(cnt == b)
return;
if(!vis[e])
dfs(e);
}
return ;
}
vi find_split(int N, int A, int B, int C, vi P, vi Q)
{
n = N, a = A, b = B, c = C;
m = P.size();
for(int i =0 ; i < n; i++)
adj[i].clear();
for(int i = 0; i < m; i ++)
{
adj[P[i]].pb(Q[i]);
adj[Q[i]].pb(P[i]);
}
ans.assign(n, 0);
dfs(0);
bool flag = false;
for(int i = 0; i < n; i++)
{
if(ans[i] == 0)
{
if(flag)
ans[i] = 3;
else
ans[i] = 1;
}
}
return ans;
}
/*
int32_t main()
{
int N, M, A, B, C;
cin >> N >> M >> A >> B >> C;
vi P(M), Q(M);
for(int i = 0; i < M; i++)
cin >> P[i] >> Q[i];
vi ANS = find_split(N, A, B, C, P, Q);
for(auto e: ANS)
cout << e << ' ';
}
*/
# | 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... |