#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 10;
struct EDGE{
int to , id;
};
int n , m , col[N];
vector <EDGE> adj[N];
vector <int> r;
bool marked[N] , dead[N] , vis[N];
void Dfs(int v)
{
marked[v] = true;
for(auto u : adj[v]) if(!marked[u.to] && !dead[u.to])
{
r.push_back(u.id);
col[u.to] = col[v];
Dfs(u.to);
}
}
vector<int> find_roads(int nn, vector<int> u, vector<int> v) {
n = nn;
m = u.size();
for(int i = 0 ; i < m ; i++)
{
adj[u[i]].push_back({v[i] , i});
adj[v[i]].push_back({u[i] , i});
}
int star = 0;
vector <int> cand;
dead[star] = true;
cand.push_back(star);
vector <int> cor;
while(!cand.empty())
{
vector <EDGE> add;
r = cor;
for(int i = 0 ; i < n ; i++)
{
marked[i] = false;
vis[i] = false;
}
int coco = 0;
for(int i = 0 ; i < n ; i++) if(!dead[i] && !marked[i])
{
col[i] = coco;
Dfs(i);
coco++;
}
for(int asd = 0 ; asd < coco ; asd++)
{
int mx = 0;
vector <EDGE> fake;
for(int i = 0 ; i < coco ; i++)
vis[i] = false;
for(auto v : cand) for(auto u : adj[v]) if(!dead[u.to] && col[u.to] != asd && !vis[col[u.to]])
{
r.push_back(u.id);
vis[col[u.to]] = true;
}
for(auto v : cand) for(auto u : adj[v]) if(!dead[u.to] && col[u.to] == asd)
{
r.push_back(u.id);
int now = count_common_roads(r);
if(now > mx)
{
mx = now;
fake.clear();
}
if(now == mx)
fake.push_back(u);
r.pop_back();
}
for(int i = 0 ; i < coco - 1 ; i++)
r.pop_back();
for(auto u : fake)
add.push_back(u);
}
cand.clear();
for(auto u : add)
{
cor.push_back(u.id);
dead[u.to] = true;
cand.push_back(u.to);
}
}
return cor;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
correct |
2 |
Correct |
1 ms |
348 KB |
correct |
3 |
Correct |
1 ms |
344 KB |
correct |
4 |
Correct |
1 ms |
348 KB |
correct |
5 |
Correct |
1 ms |
452 KB |
correct |
6 |
Correct |
1 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Correct |
1 ms |
344 KB |
correct |
10 |
Correct |
0 ms |
348 KB |
correct |
11 |
Correct |
1 ms |
604 KB |
correct |
12 |
Correct |
0 ms |
348 KB |
correct |
13 |
Correct |
1 ms |
348 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
correct |
2 |
Correct |
1 ms |
348 KB |
correct |
3 |
Correct |
1 ms |
344 KB |
correct |
4 |
Correct |
1 ms |
348 KB |
correct |
5 |
Correct |
1 ms |
452 KB |
correct |
6 |
Correct |
1 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Correct |
1 ms |
344 KB |
correct |
10 |
Correct |
0 ms |
348 KB |
correct |
11 |
Correct |
1 ms |
604 KB |
correct |
12 |
Correct |
0 ms |
348 KB |
correct |
13 |
Correct |
1 ms |
348 KB |
correct |
14 |
Correct |
1 ms |
348 KB |
correct |
15 |
Correct |
1 ms |
348 KB |
correct |
16 |
Correct |
1 ms |
348 KB |
correct |
17 |
Correct |
1 ms |
348 KB |
correct |
18 |
Correct |
1 ms |
348 KB |
correct |
19 |
Correct |
2 ms |
348 KB |
correct |
20 |
Correct |
1 ms |
348 KB |
correct |
21 |
Correct |
1 ms |
348 KB |
correct |
22 |
Correct |
1 ms |
348 KB |
correct |
23 |
Correct |
1 ms |
348 KB |
correct |
24 |
Correct |
1 ms |
348 KB |
correct |
25 |
Correct |
0 ms |
348 KB |
correct |
26 |
Correct |
1 ms |
348 KB |
correct |
27 |
Correct |
1 ms |
348 KB |
correct |
28 |
Correct |
1 ms |
348 KB |
correct |
29 |
Correct |
0 ms |
348 KB |
correct |
30 |
Correct |
1 ms |
596 KB |
correct |
31 |
Correct |
1 ms |
344 KB |
correct |
32 |
Correct |
1 ms |
344 KB |
correct |
33 |
Correct |
1 ms |
456 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
correct |
2 |
Correct |
1 ms |
348 KB |
correct |
3 |
Correct |
1 ms |
344 KB |
correct |
4 |
Correct |
1 ms |
348 KB |
correct |
5 |
Correct |
1 ms |
452 KB |
correct |
6 |
Correct |
1 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Correct |
1 ms |
344 KB |
correct |
10 |
Correct |
0 ms |
348 KB |
correct |
11 |
Correct |
1 ms |
604 KB |
correct |
12 |
Correct |
0 ms |
348 KB |
correct |
13 |
Correct |
1 ms |
348 KB |
correct |
14 |
Correct |
1 ms |
348 KB |
correct |
15 |
Correct |
1 ms |
348 KB |
correct |
16 |
Correct |
1 ms |
348 KB |
correct |
17 |
Correct |
1 ms |
348 KB |
correct |
18 |
Correct |
1 ms |
348 KB |
correct |
19 |
Correct |
2 ms |
348 KB |
correct |
20 |
Correct |
1 ms |
348 KB |
correct |
21 |
Correct |
1 ms |
348 KB |
correct |
22 |
Correct |
1 ms |
348 KB |
correct |
23 |
Correct |
1 ms |
348 KB |
correct |
24 |
Correct |
1 ms |
348 KB |
correct |
25 |
Correct |
0 ms |
348 KB |
correct |
26 |
Correct |
1 ms |
348 KB |
correct |
27 |
Correct |
1 ms |
348 KB |
correct |
28 |
Correct |
1 ms |
348 KB |
correct |
29 |
Correct |
0 ms |
348 KB |
correct |
30 |
Correct |
1 ms |
596 KB |
correct |
31 |
Correct |
1 ms |
344 KB |
correct |
32 |
Correct |
1 ms |
344 KB |
correct |
33 |
Correct |
1 ms |
456 KB |
correct |
34 |
Correct |
86 ms |
1628 KB |
correct |
35 |
Correct |
84 ms |
1680 KB |
correct |
36 |
Correct |
46 ms |
1368 KB |
correct |
37 |
Correct |
4 ms |
348 KB |
correct |
38 |
Correct |
87 ms |
1632 KB |
correct |
39 |
Correct |
40 ms |
1620 KB |
correct |
40 |
Correct |
47 ms |
1492 KB |
correct |
41 |
Correct |
7 ms |
1624 KB |
correct |
42 |
Correct |
8 ms |
1716 KB |
correct |
43 |
Correct |
44 ms |
1116 KB |
correct |
44 |
Correct |
32 ms |
856 KB |
correct |
45 |
Correct |
39 ms |
1080 KB |
correct |
46 |
Correct |
35 ms |
860 KB |
correct |
47 |
Correct |
13 ms |
604 KB |
correct |
48 |
Correct |
2 ms |
348 KB |
correct |
49 |
Correct |
4 ms |
348 KB |
correct |
50 |
Correct |
12 ms |
720 KB |
correct |
51 |
Correct |
46 ms |
1128 KB |
correct |
52 |
Correct |
32 ms |
860 KB |
correct |
53 |
Correct |
29 ms |
724 KB |
correct |
54 |
Correct |
41 ms |
1116 KB |
correct |
55 |
Correct |
51 ms |
860 KB |
correct |
56 |
Correct |
41 ms |
860 KB |
correct |
57 |
Correct |
41 ms |
1104 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
correct |
2 |
Correct |
0 ms |
348 KB |
correct |
3 |
Incorrect |
65 ms |
3896 KB |
WA in grader: NO |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
correct |
2 |
Correct |
1 ms |
348 KB |
correct |
3 |
Correct |
1 ms |
344 KB |
correct |
4 |
Correct |
1 ms |
348 KB |
correct |
5 |
Correct |
1 ms |
452 KB |
correct |
6 |
Correct |
1 ms |
348 KB |
correct |
7 |
Correct |
0 ms |
348 KB |
correct |
8 |
Correct |
0 ms |
348 KB |
correct |
9 |
Correct |
1 ms |
344 KB |
correct |
10 |
Correct |
0 ms |
348 KB |
correct |
11 |
Correct |
1 ms |
604 KB |
correct |
12 |
Correct |
0 ms |
348 KB |
correct |
13 |
Correct |
1 ms |
348 KB |
correct |
14 |
Correct |
1 ms |
348 KB |
correct |
15 |
Correct |
1 ms |
348 KB |
correct |
16 |
Correct |
1 ms |
348 KB |
correct |
17 |
Correct |
1 ms |
348 KB |
correct |
18 |
Correct |
1 ms |
348 KB |
correct |
19 |
Correct |
2 ms |
348 KB |
correct |
20 |
Correct |
1 ms |
348 KB |
correct |
21 |
Correct |
1 ms |
348 KB |
correct |
22 |
Correct |
1 ms |
348 KB |
correct |
23 |
Correct |
1 ms |
348 KB |
correct |
24 |
Correct |
1 ms |
348 KB |
correct |
25 |
Correct |
0 ms |
348 KB |
correct |
26 |
Correct |
1 ms |
348 KB |
correct |
27 |
Correct |
1 ms |
348 KB |
correct |
28 |
Correct |
1 ms |
348 KB |
correct |
29 |
Correct |
0 ms |
348 KB |
correct |
30 |
Correct |
1 ms |
596 KB |
correct |
31 |
Correct |
1 ms |
344 KB |
correct |
32 |
Correct |
1 ms |
344 KB |
correct |
33 |
Correct |
1 ms |
456 KB |
correct |
34 |
Correct |
86 ms |
1628 KB |
correct |
35 |
Correct |
84 ms |
1680 KB |
correct |
36 |
Correct |
46 ms |
1368 KB |
correct |
37 |
Correct |
4 ms |
348 KB |
correct |
38 |
Correct |
87 ms |
1632 KB |
correct |
39 |
Correct |
40 ms |
1620 KB |
correct |
40 |
Correct |
47 ms |
1492 KB |
correct |
41 |
Correct |
7 ms |
1624 KB |
correct |
42 |
Correct |
8 ms |
1716 KB |
correct |
43 |
Correct |
44 ms |
1116 KB |
correct |
44 |
Correct |
32 ms |
856 KB |
correct |
45 |
Correct |
39 ms |
1080 KB |
correct |
46 |
Correct |
35 ms |
860 KB |
correct |
47 |
Correct |
13 ms |
604 KB |
correct |
48 |
Correct |
2 ms |
348 KB |
correct |
49 |
Correct |
4 ms |
348 KB |
correct |
50 |
Correct |
12 ms |
720 KB |
correct |
51 |
Correct |
46 ms |
1128 KB |
correct |
52 |
Correct |
32 ms |
860 KB |
correct |
53 |
Correct |
29 ms |
724 KB |
correct |
54 |
Correct |
41 ms |
1116 KB |
correct |
55 |
Correct |
51 ms |
860 KB |
correct |
56 |
Correct |
41 ms |
860 KB |
correct |
57 |
Correct |
41 ms |
1104 KB |
correct |
58 |
Correct |
1 ms |
348 KB |
correct |
59 |
Correct |
0 ms |
348 KB |
correct |
60 |
Incorrect |
65 ms |
3896 KB |
WA in grader: NO |
61 |
Halted |
0 ms |
0 KB |
- |