# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1100248 | 2024-10-13T10:49:57 Z | MMihalev | Simurgh (IOI17_simurgh) | C++14 | 100 ms | 3668 KB |
#include<iostream> #include<algorithm> #include<set> #include<queue> #include "simurgh.h" using namespace std; const int MAX_N=5e2+3; const int MAX_M=125000; int n,m; int q; vector<int>edges; vector<pair<int,int>>g[MAX_N]; bool used[MAX_N]; vector<int>comp; vector<vector<int>>comps; int adj[MAX_N]; bool stat[MAX_M]; bool checked[MAX_M]; int forsure; void reset() { comps.clear(); edges.clear(); for(int i=0;i<n;i++) { adj[i]=-1; used[i]=0; } } void dfs(int u) { if(adj[u]!=-1) { if(!checked[adj[u]]) { if(stat[adj[u]])while(1); comp.push_back(adj[u]); } if(stat[adj[u]])forsure=adj[u]; } used[u]=1; for(auto [v,edge]:g[u]) { if(used[v])continue; edges.push_back(edge); dfs(v); } } void rep(int prev,int edge) { for(int i=0;i<edges.size();i++) { if(edges[i]==prev){edges[i]=edge;return;} } while(1); } vector<int> find_roads(int N, vector<int> u, vector<int> v) { n=N; m=u.size(); vector<int>ans; //for(int i=0;i<n;i++)g[i].clear(); for(int i=0;i<m;i++) { //stat[i]=0; //checked[i]=0; g[u[i]].push_back({v[i],i}); g[v[i]].push_back({u[i],i}); } for(int u=0;u<n;u++) { reset(); used[u]=1; for(auto [v,edge]:g[u]) { adj[v]=edge; } for(auto [v,edge]:g[u]) { if(!used[v]) { forsure=-1; comp.clear(); dfs(v); if(forsure!=-1) { comp.push_back(forsure); } comps.push_back(comp); } } for(auto c:comps) { edges.push_back(c[0]); } for(auto c:comps) { if(q==30000)while(1); if(edges.size()!=n-1)while(1); int ma=count_common_roads(edges);q++; vector<int>marked; marked.push_back(c[0]); int prev=c[0]; for(int edge:c) { if(edge==c[0])continue; rep(prev,edge); if(edges.size()!=n-1)while(1); if(q==30000)while(1); int cur=count_common_roads(edges);q++; if(cur>ma) { marked.clear(); ma=cur; marked.push_back(edge); } else if(cur==ma) { marked.push_back(edge); } prev=edge; } for(int edge:marked)stat[edge]=1; } for(auto [v,edge]:g[u])checked[edge]=1; } for(int i=0;i<m;i++) { if(stat[i])ans.push_back(i); } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | correct |
2 | Correct | 1 ms | 336 KB | correct |
3 | Correct | 1 ms | 336 KB | correct |
4 | Correct | 1 ms | 336 KB | correct |
5 | Correct | 1 ms | 336 KB | correct |
6 | Correct | 1 ms | 336 KB | correct |
7 | Correct | 1 ms | 336 KB | correct |
8 | Correct | 1 ms | 336 KB | correct |
9 | Correct | 1 ms | 336 KB | correct |
10 | Correct | 1 ms | 336 KB | correct |
11 | Correct | 1 ms | 336 KB | correct |
12 | Correct | 1 ms | 336 KB | correct |
13 | Correct | 1 ms | 404 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | correct |
2 | Correct | 1 ms | 336 KB | correct |
3 | Correct | 1 ms | 336 KB | correct |
4 | Correct | 1 ms | 336 KB | correct |
5 | Correct | 1 ms | 336 KB | correct |
6 | Correct | 1 ms | 336 KB | correct |
7 | Correct | 1 ms | 336 KB | correct |
8 | Correct | 1 ms | 336 KB | correct |
9 | Correct | 1 ms | 336 KB | correct |
10 | Correct | 1 ms | 336 KB | correct |
11 | Correct | 1 ms | 336 KB | correct |
12 | Correct | 1 ms | 336 KB | correct |
13 | Correct | 1 ms | 404 KB | correct |
14 | Correct | 2 ms | 336 KB | correct |
15 | Correct | 2 ms | 336 KB | correct |
16 | Correct | 2 ms | 516 KB | correct |
17 | Correct | 2 ms | 336 KB | correct |
18 | Correct | 2 ms | 336 KB | correct |
19 | Correct | 1 ms | 336 KB | correct |
20 | Correct | 1 ms | 336 KB | correct |
21 | Correct | 2 ms | 336 KB | correct |
22 | Correct | 1 ms | 336 KB | correct |
23 | Correct | 1 ms | 336 KB | correct |
24 | Correct | 2 ms | 336 KB | correct |
25 | Correct | 1 ms | 508 KB | correct |
26 | Correct | 1 ms | 336 KB | correct |
27 | Correct | 1 ms | 336 KB | correct |
28 | Correct | 1 ms | 336 KB | correct |
29 | Correct | 2 ms | 336 KB | correct |
30 | Correct | 1 ms | 336 KB | correct |
31 | Correct | 1 ms | 336 KB | correct |
32 | Correct | 1 ms | 336 KB | correct |
33 | Correct | 1 ms | 336 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | correct |
2 | Correct | 1 ms | 336 KB | correct |
3 | Correct | 1 ms | 336 KB | correct |
4 | Correct | 1 ms | 336 KB | correct |
5 | Correct | 1 ms | 336 KB | correct |
6 | Correct | 1 ms | 336 KB | correct |
7 | Correct | 1 ms | 336 KB | correct |
8 | Correct | 1 ms | 336 KB | correct |
9 | Correct | 1 ms | 336 KB | correct |
10 | Correct | 1 ms | 336 KB | correct |
11 | Correct | 1 ms | 336 KB | correct |
12 | Correct | 1 ms | 336 KB | correct |
13 | Correct | 1 ms | 404 KB | correct |
14 | Correct | 2 ms | 336 KB | correct |
15 | Correct | 2 ms | 336 KB | correct |
16 | Correct | 2 ms | 516 KB | correct |
17 | Correct | 2 ms | 336 KB | correct |
18 | Correct | 2 ms | 336 KB | correct |
19 | Correct | 1 ms | 336 KB | correct |
20 | Correct | 1 ms | 336 KB | correct |
21 | Correct | 2 ms | 336 KB | correct |
22 | Correct | 1 ms | 336 KB | correct |
23 | Correct | 1 ms | 336 KB | correct |
24 | Correct | 2 ms | 336 KB | correct |
25 | Correct | 1 ms | 508 KB | correct |
26 | Correct | 1 ms | 336 KB | correct |
27 | Correct | 1 ms | 336 KB | correct |
28 | Correct | 1 ms | 336 KB | correct |
29 | Correct | 2 ms | 336 KB | correct |
30 | Correct | 1 ms | 336 KB | correct |
31 | Correct | 1 ms | 336 KB | correct |
32 | Correct | 1 ms | 336 KB | correct |
33 | Correct | 1 ms | 336 KB | correct |
34 | Correct | 100 ms | 1360 KB | correct |
35 | Correct | 89 ms | 1536 KB | correct |
36 | Correct | 63 ms | 1360 KB | correct |
37 | Correct | 7 ms | 336 KB | correct |
38 | Correct | 92 ms | 1532 KB | correct |
39 | Correct | 80 ms | 1488 KB | correct |
40 | Correct | 66 ms | 1360 KB | correct |
41 | Correct | 92 ms | 1360 KB | correct |
42 | Correct | 98 ms | 1360 KB | correct |
43 | Correct | 52 ms | 1108 KB | correct |
44 | Correct | 41 ms | 964 KB | correct |
45 | Correct | 49 ms | 848 KB | correct |
46 | Correct | 37 ms | 848 KB | correct |
47 | Correct | 17 ms | 592 KB | correct |
48 | Correct | 3 ms | 336 KB | correct |
49 | Correct | 6 ms | 336 KB | correct |
50 | Correct | 17 ms | 592 KB | correct |
51 | Correct | 50 ms | 848 KB | correct |
52 | Correct | 41 ms | 848 KB | correct |
53 | Correct | 37 ms | 848 KB | correct |
54 | Correct | 51 ms | 1104 KB | correct |
55 | Correct | 47 ms | 848 KB | correct |
56 | Correct | 47 ms | 848 KB | correct |
57 | Correct | 48 ms | 1016 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | correct |
2 | Correct | 1 ms | 336 KB | correct |
3 | Incorrect | 70 ms | 3668 KB | WA in grader: NO |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | correct |
2 | Correct | 1 ms | 336 KB | correct |
3 | Correct | 1 ms | 336 KB | correct |
4 | Correct | 1 ms | 336 KB | correct |
5 | Correct | 1 ms | 336 KB | correct |
6 | Correct | 1 ms | 336 KB | correct |
7 | Correct | 1 ms | 336 KB | correct |
8 | Correct | 1 ms | 336 KB | correct |
9 | Correct | 1 ms | 336 KB | correct |
10 | Correct | 1 ms | 336 KB | correct |
11 | Correct | 1 ms | 336 KB | correct |
12 | Correct | 1 ms | 336 KB | correct |
13 | Correct | 1 ms | 404 KB | correct |
14 | Correct | 2 ms | 336 KB | correct |
15 | Correct | 2 ms | 336 KB | correct |
16 | Correct | 2 ms | 516 KB | correct |
17 | Correct | 2 ms | 336 KB | correct |
18 | Correct | 2 ms | 336 KB | correct |
19 | Correct | 1 ms | 336 KB | correct |
20 | Correct | 1 ms | 336 KB | correct |
21 | Correct | 2 ms | 336 KB | correct |
22 | Correct | 1 ms | 336 KB | correct |
23 | Correct | 1 ms | 336 KB | correct |
24 | Correct | 2 ms | 336 KB | correct |
25 | Correct | 1 ms | 508 KB | correct |
26 | Correct | 1 ms | 336 KB | correct |
27 | Correct | 1 ms | 336 KB | correct |
28 | Correct | 1 ms | 336 KB | correct |
29 | Correct | 2 ms | 336 KB | correct |
30 | Correct | 1 ms | 336 KB | correct |
31 | Correct | 1 ms | 336 KB | correct |
32 | Correct | 1 ms | 336 KB | correct |
33 | Correct | 1 ms | 336 KB | correct |
34 | Correct | 100 ms | 1360 KB | correct |
35 | Correct | 89 ms | 1536 KB | correct |
36 | Correct | 63 ms | 1360 KB | correct |
37 | Correct | 7 ms | 336 KB | correct |
38 | Correct | 92 ms | 1532 KB | correct |
39 | Correct | 80 ms | 1488 KB | correct |
40 | Correct | 66 ms | 1360 KB | correct |
41 | Correct | 92 ms | 1360 KB | correct |
42 | Correct | 98 ms | 1360 KB | correct |
43 | Correct | 52 ms | 1108 KB | correct |
44 | Correct | 41 ms | 964 KB | correct |
45 | Correct | 49 ms | 848 KB | correct |
46 | Correct | 37 ms | 848 KB | correct |
47 | Correct | 17 ms | 592 KB | correct |
48 | Correct | 3 ms | 336 KB | correct |
49 | Correct | 6 ms | 336 KB | correct |
50 | Correct | 17 ms | 592 KB | correct |
51 | Correct | 50 ms | 848 KB | correct |
52 | Correct | 41 ms | 848 KB | correct |
53 | Correct | 37 ms | 848 KB | correct |
54 | Correct | 51 ms | 1104 KB | correct |
55 | Correct | 47 ms | 848 KB | correct |
56 | Correct | 47 ms | 848 KB | correct |
57 | Correct | 48 ms | 1016 KB | correct |
58 | Correct | 1 ms | 336 KB | correct |
59 | Correct | 1 ms | 336 KB | correct |
60 | Incorrect | 70 ms | 3668 KB | WA in grader: NO |
61 | Halted | 0 ms | 0 KB | - |