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 sz(x) (int)x.size()
#define mkt make_tuple
#define lp(i,a,b) for(int i = a ; i < b ; i++ )
#define ff first
#define ss second
#define eb emplace_back
#define ll long long
#define mk make_pair
#define pii pair<int,int>
#define debug printf
#define all(x) x.begin(),x.end()
const int MAXN = 1e5+10 ;
using namespace std ;
vector< vector<int> > adj ;
vector<int> vec ;
bool vis[MAXN] ;
int sobra , curr ;
void dfs(int x )
{
vis[x] = true ;
vec[x-1] = curr ;
sobra-- ;
for(auto e : adj[x])
if(!vis[e] && sobra > 0) dfs(e) ;
}
vector<int> find_split(int n , int a , int b , int c , vector<int> p ,vector<int> q )
{
lp(i,0,n) vec.emplace_back(0) ;
for(int i = 0 ; i <= n ; i++ ) adj.emplace_back( *(new vector<int>) ) ;
for(int i = 0 ; i < sz(p) ; i++ ) adj[ p[i]+1 ].emplace_back( q[i]+1 ) , adj[ q[i]+1 ].emplace_back(p[i]+1) ;
int x = 1 ;
lp(i,1,n+1)
if( sz(adj[i]) < sz(adj[x]) ) x = i ;
sobra = a ;
curr = 1 ;
dfs(x) ;
sobra = b ;
curr = 2 ;
lp(i,1,n+1)
if(!vis[i])
{
dfs(i) ;
break ;
}
lp(i,1,n+1)
if(!vis[i]) vec[i-1] = 3 ;
return vec ;
}
# | 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... |