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>
using namespace std;
#define pb push_back
#define C continue
typedef vector < int > vi ;
#include "split.h"
int n , m , goal ;
vi v [100009] , ret ;
int done [100009] ;
void dfs ( int node ) {
if ( ret .size () == goal ) return ;
done [node] = 1 ;
ret .pb ( node ) ;
for ( auto u : v [node] ) {
if ( done [u] ) C ;
dfs ( u ) ;
}
}
vi find_split ( int N , int sz1 , int sz2 , int sz3 , vi p , vi q ) {
n = N , m = p .size () , goal = sz2 ;
for ( int i = 0 ; i < m ; i ++ ) {
int a , b ;
a = p [i] , b = q [i] ;
v [a] .pb ( b ) ;
v [b] .pb ( a ) ;
}
dfs ( 0 ) ;
vi ans ( n , 0 ) ;
for ( auto u : ret ) {
ans [u] = 2 ;
}
for ( auto &u : ans ) {
if ( ! u ) {
u = 1 ;
break ;
}
}
for ( auto &u : ans ) {
if ( ! u ) {
u = 3 ;
}
}
return ans ;
}
Compilation message (stderr)
split.cpp: In function 'void dfs(int)':
split.cpp:11:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
11 | if ( ret .size () == goal ) return ;
| ~~~~~~~~~~~~~^~~~~~~
# | 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... |