#include <algorithm>
#include <iostream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define N 500005
#define ll long long int
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define fs(ar,n) fo(i,1,n) cin>>ar[i]
#define sp " "
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast2 freopen ("in.txt","r",stdin);freopen ("out.txt","w",stdout);
#define inf 1000000000
using namespace std;
#include "split.h"
using namespace std;
ll nn,mm,x,y,z;
vector<int> v[N],ans(nn);
void f(int ind,int back)
{
// cerr<<ind<<endl;
if(!x && !y && !z)
return;
if(x)
ans[ind]=1,x--;
else if(y)
ans[ind]=2,y--;
else
ans[ind]=3,z--;
for(int i=0;i<v[ind].size();i++)
{
int xx=v[ind][i];
if(xx!=back)
f(xx,ind);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
mm=p.size();
nn=n;
x=a;
y=b;
z=c;
int rt=0;
fo(i,0,mm-1)
{
int at=p[i];
int bt=q[i];
v[at].pb(bt);
v[bt].pb(at);
}
// cerr<<ans.size()<<endl;
ans.resize(nn);
fo(i,0,nn-1)
if(v[i].size()<2)
rt=i;
f(rt,rt);
return ans;
}
// int main() {
// int n, m, a, b, c;
// assert(5 == scanf("%d%d%d%d%d", &n, &m, &a, &b, &c));
// vector<int> p(m), q(m);
// for (int i=0; i<m; i++)
// assert(2 == scanf("%d%d", &p[i], &q[i]));
// fclose(stdin);
// vector<int> result = find_split(n, a, b, c, p, q);
// for (int i=0; i<(int)result.size(); i++)
// printf("%s%d", ((i>0)?" ":""), result[i]);
// printf("\n");
// fclose(stdout);
// return 0;
// }
Compilation message
split.cpp: In function 'void f(int, int)':
split.cpp:52:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i=0;i<v[ind].size();i++)
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
12032 KB |
ok, correct split |
2 |
Correct |
8 ms |
12032 KB |
ok, correct split |
3 |
Correct |
8 ms |
12032 KB |
ok, correct split |
4 |
Correct |
9 ms |
12032 KB |
ok, correct split |
5 |
Correct |
9 ms |
12032 KB |
ok, correct split |
6 |
Correct |
9 ms |
12032 KB |
ok, correct split |
7 |
Correct |
104 ms |
22392 KB |
ok, correct split |
8 |
Correct |
108 ms |
22264 KB |
ok, correct split |
9 |
Correct |
104 ms |
22240 KB |
ok, correct split |
10 |
Correct |
110 ms |
22264 KB |
ok, correct split |
11 |
Correct |
104 ms |
22268 KB |
ok, correct split |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
12032 KB |
ok, correct split |
2 |
Correct |
8 ms |
12032 KB |
ok, correct split |
3 |
Incorrect |
8 ms |
12032 KB |
answer contains both zero and positive values |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
12032 KB |
ok, correct split |
2 |
Incorrect |
89 ms |
17656 KB |
2 components are not connected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
12032 KB |
answer contains both zero and positive values |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
12032 KB |
ok, correct split |
2 |
Correct |
8 ms |
12032 KB |
ok, correct split |
3 |
Correct |
8 ms |
12032 KB |
ok, correct split |
4 |
Correct |
9 ms |
12032 KB |
ok, correct split |
5 |
Correct |
9 ms |
12032 KB |
ok, correct split |
6 |
Correct |
9 ms |
12032 KB |
ok, correct split |
7 |
Correct |
104 ms |
22392 KB |
ok, correct split |
8 |
Correct |
108 ms |
22264 KB |
ok, correct split |
9 |
Correct |
104 ms |
22240 KB |
ok, correct split |
10 |
Correct |
110 ms |
22264 KB |
ok, correct split |
11 |
Correct |
104 ms |
22268 KB |
ok, correct split |
12 |
Correct |
9 ms |
12032 KB |
ok, correct split |
13 |
Correct |
8 ms |
12032 KB |
ok, correct split |
14 |
Incorrect |
8 ms |
12032 KB |
answer contains both zero and positive values |
15 |
Halted |
0 ms |
0 KB |
- |