#include "split.h"
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,t,a[5],rs[nmax],x,vz[nmax];
vector<int>vc,g[nmax];
void dfs(int x)
{
vz[x]=1;
while(!a[t])t++;
a[t]--;
rs[x]=t;
for(int i=0;i<g[x].size();i++)
{
if(!vz[g[x][i]])dfs(g[x][i]);
}
}
vector<int> find_split(int N, int A, int B, int C, vector<int> P, vector<int> Q)
{
n=N,a[1]=A,a[2]=B,a[3]=C,m=P.size();
for(i=0;i<m;i++)
{
P[i]++,Q[i]++;
g[P[i]].pb(Q[i]);
g[Q[i]].pb(P[i]);
}
for(i=1;i<=n;i++)if(g[i].size()==1)break;
x=i,t=1;
if(x==n+1)x=1;
dfs(x);
for(i=1;i<=n;i++)vc.pb(rs[i]);
return vc;
}
Compilation message
split.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("O3")
split.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("unroll-loops")
split.cpp: In function 'void dfs(int)':
split.cpp:30:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<g[x].size();i++)
~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
ok, correct split |
2 |
Correct |
4 ms |
2680 KB |
ok, correct split |
3 |
Correct |
4 ms |
2680 KB |
ok, correct split |
4 |
Correct |
4 ms |
2680 KB |
ok, correct split |
5 |
Correct |
4 ms |
2808 KB |
ok, correct split |
6 |
Correct |
4 ms |
2684 KB |
ok, correct split |
7 |
Correct |
84 ms |
13348 KB |
ok, correct split |
8 |
Correct |
88 ms |
13364 KB |
ok, correct split |
9 |
Correct |
91 ms |
13300 KB |
ok, correct split |
10 |
Correct |
91 ms |
13348 KB |
ok, correct split |
11 |
Correct |
93 ms |
13300 KB |
ok, correct split |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
ok, correct split |
2 |
Correct |
4 ms |
2676 KB |
ok, correct split |
3 |
Correct |
4 ms |
2680 KB |
ok, correct split |
4 |
Correct |
137 ms |
13296 KB |
ok, correct split |
5 |
Correct |
95 ms |
10484 KB |
ok, correct split |
6 |
Correct |
87 ms |
13300 KB |
ok, correct split |
7 |
Correct |
91 ms |
13428 KB |
ok, correct split |
8 |
Correct |
135 ms |
12120 KB |
ok, correct split |
9 |
Correct |
81 ms |
9048 KB |
ok, correct split |
10 |
Correct |
64 ms |
9428 KB |
ok, correct split |
11 |
Correct |
64 ms |
9428 KB |
ok, correct split |
12 |
Correct |
68 ms |
9452 KB |
ok, correct split |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
ok, correct split |
2 |
Incorrect |
84 ms |
10356 KB |
2 components are not connected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
2680 KB |
2 components are not connected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
ok, correct split |
2 |
Correct |
4 ms |
2680 KB |
ok, correct split |
3 |
Correct |
4 ms |
2680 KB |
ok, correct split |
4 |
Correct |
4 ms |
2680 KB |
ok, correct split |
5 |
Correct |
4 ms |
2808 KB |
ok, correct split |
6 |
Correct |
4 ms |
2684 KB |
ok, correct split |
7 |
Correct |
84 ms |
13348 KB |
ok, correct split |
8 |
Correct |
88 ms |
13364 KB |
ok, correct split |
9 |
Correct |
91 ms |
13300 KB |
ok, correct split |
10 |
Correct |
91 ms |
13348 KB |
ok, correct split |
11 |
Correct |
93 ms |
13300 KB |
ok, correct split |
12 |
Correct |
4 ms |
2680 KB |
ok, correct split |
13 |
Correct |
4 ms |
2676 KB |
ok, correct split |
14 |
Correct |
4 ms |
2680 KB |
ok, correct split |
15 |
Correct |
137 ms |
13296 KB |
ok, correct split |
16 |
Correct |
95 ms |
10484 KB |
ok, correct split |
17 |
Correct |
87 ms |
13300 KB |
ok, correct split |
18 |
Correct |
91 ms |
13428 KB |
ok, correct split |
19 |
Correct |
135 ms |
12120 KB |
ok, correct split |
20 |
Correct |
81 ms |
9048 KB |
ok, correct split |
21 |
Correct |
64 ms |
9428 KB |
ok, correct split |
22 |
Correct |
64 ms |
9428 KB |
ok, correct split |
23 |
Correct |
68 ms |
9452 KB |
ok, correct split |
24 |
Correct |
4 ms |
2680 KB |
ok, correct split |
25 |
Incorrect |
84 ms |
10356 KB |
2 components are not connected |
26 |
Halted |
0 ms |
0 KB |
- |