# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
804421 | 2023-08-03T08:38:24 Z | ngrace | Simurgh (IOI17_simurgh) | C++14 | 113 ms | 3448 KB |
#include "simurgh.h" //could probs be optimised to not tle on sub3 #include <bits/stdc++.h> using namespace std; #define ve vector #define ll long long #define ii pair<int, int> #define fi first #define se second int N; set<int> ans; int edgeInd[240][240]; struct DSU{ int par[500]; int si=0; DSU(int siz){ si=siz; reset(); } void reset(){ for(int i=0; i<si; i++) par[i]=i; } int root(int x) { return (x==par[x]) ? x : par[x]=root(par[x]); } void doUnion(int a, int b){ par[root(a)]=root(b); } }; std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { N = n; if(n==2){ ve<int> res = {0}; return res; } for(int i=0; i<240; i++){ for(int j=0; j<240; j++){ edgeInd[i][j] = -1; } } for(int i=0; i < u.size(); i++){ edgeInd[u[i]][v[i]] = i; edgeInd[v[i]][u[i]] = i; } ve<ve<bool>> known(N, ve<bool>(N, false)); for(int i=0; i<N; i++){ ve<int> tree; DSU comp(N); for(int a=0; a<N; a++){ if(a==i) continue; for(int b=a+1; b<N; b++){ if(b==i || edgeInd[a][b]==-1) continue; if(comp.root(a)==comp.root(b)) continue; tree.push_back(edgeInd[a][b]); comp.doUnion(a, b); } } set<int> comps; for(int a=0; a<N; a++){ if(a==i) continue; comps.insert(comp.root(a)); } ve<ve<int>> compGroups; for(int a:comps){ compGroups.push_back({}); for(int b=0; b<N; b++){ if(comp.root(a)==comp.root(b) && edgeInd[i][b]!=-1) compGroups.back().push_back(b); } } for(int j=0; j<compGroups.size(); j++){ for(int tmp=0; tmp<compGroups.size(); tmp++){ if(tmp==j) continue; tree.push_back(edgeInd[i][compGroups[tmp][0]]); } int ma=0; ve<int> cou(N, -1); bool first=true; for(int node:compGroups[j]){ if(known[i][node]){ cou[node] = -1; if(ans.find(edgeInd[i][node])==ans.end() || !first) continue; first=false; } tree.push_back(edgeInd[i][node]); cou[node] = count_common_roads(tree); ma = max(ma, cou[node]); tree.pop_back(); known[i][node] = known[node][i] = true; } for(int node:compGroups[j]){ if(cou[node]<ma) continue; //cout<<"Edge from "<<i<<" to "<<node<<endl; ans.insert(edgeInd[i][node]); } for(int tmp=0; tmp<compGroups.size()-1; tmp++) tree.pop_back(); } } ve<int> res; for(int i:ans) res.push_back(i); return res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | correct |
2 | Correct | 1 ms | 432 KB | correct |
3 | Correct | 1 ms | 432 KB | correct |
4 | Correct | 1 ms | 468 KB | correct |
5 | Correct | 1 ms | 468 KB | correct |
6 | Correct | 1 ms | 468 KB | correct |
7 | Correct | 1 ms | 212 KB | correct |
8 | Correct | 1 ms | 468 KB | correct |
9 | Correct | 1 ms | 468 KB | correct |
10 | Correct | 1 ms | 524 KB | correct |
11 | Correct | 1 ms | 468 KB | correct |
12 | Correct | 1 ms | 468 KB | correct |
13 | Correct | 1 ms | 468 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | correct |
2 | Correct | 1 ms | 432 KB | correct |
3 | Correct | 1 ms | 432 KB | correct |
4 | Correct | 1 ms | 468 KB | correct |
5 | Correct | 1 ms | 468 KB | correct |
6 | Correct | 1 ms | 468 KB | correct |
7 | Correct | 1 ms | 212 KB | correct |
8 | Correct | 1 ms | 468 KB | correct |
9 | Correct | 1 ms | 468 KB | correct |
10 | Correct | 1 ms | 524 KB | correct |
11 | Correct | 1 ms | 468 KB | correct |
12 | Correct | 1 ms | 468 KB | correct |
13 | Correct | 1 ms | 468 KB | correct |
14 | Correct | 2 ms | 440 KB | correct |
15 | Correct | 2 ms | 440 KB | correct |
16 | Correct | 2 ms | 468 KB | correct |
17 | Correct | 2 ms | 468 KB | correct |
18 | Correct | 1 ms | 468 KB | correct |
19 | Correct | 2 ms | 560 KB | correct |
20 | Correct | 2 ms | 440 KB | correct |
21 | Correct | 1 ms | 468 KB | correct |
22 | Correct | 1 ms | 468 KB | correct |
23 | Correct | 1 ms | 468 KB | correct |
24 | Correct | 1 ms | 468 KB | correct |
25 | Correct | 1 ms | 468 KB | correct |
26 | Correct | 1 ms | 436 KB | correct |
27 | Correct | 1 ms | 468 KB | correct |
28 | Correct | 1 ms | 468 KB | correct |
29 | Correct | 1 ms | 468 KB | correct |
30 | Correct | 1 ms | 468 KB | correct |
31 | Correct | 1 ms | 468 KB | correct |
32 | Correct | 1 ms | 468 KB | correct |
33 | Correct | 1 ms | 468 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | correct |
2 | Correct | 1 ms | 432 KB | correct |
3 | Correct | 1 ms | 432 KB | correct |
4 | Correct | 1 ms | 468 KB | correct |
5 | Correct | 1 ms | 468 KB | correct |
6 | Correct | 1 ms | 468 KB | correct |
7 | Correct | 1 ms | 212 KB | correct |
8 | Correct | 1 ms | 468 KB | correct |
9 | Correct | 1 ms | 468 KB | correct |
10 | Correct | 1 ms | 524 KB | correct |
11 | Correct | 1 ms | 468 KB | correct |
12 | Correct | 1 ms | 468 KB | correct |
13 | Correct | 1 ms | 468 KB | correct |
14 | Correct | 2 ms | 440 KB | correct |
15 | Correct | 2 ms | 440 KB | correct |
16 | Correct | 2 ms | 468 KB | correct |
17 | Correct | 2 ms | 468 KB | correct |
18 | Correct | 1 ms | 468 KB | correct |
19 | Correct | 2 ms | 560 KB | correct |
20 | Correct | 2 ms | 440 KB | correct |
21 | Correct | 1 ms | 468 KB | correct |
22 | Correct | 1 ms | 468 KB | correct |
23 | Correct | 1 ms | 468 KB | correct |
24 | Correct | 1 ms | 468 KB | correct |
25 | Correct | 1 ms | 468 KB | correct |
26 | Correct | 1 ms | 436 KB | correct |
27 | Correct | 1 ms | 468 KB | correct |
28 | Correct | 1 ms | 468 KB | correct |
29 | Correct | 1 ms | 468 KB | correct |
30 | Correct | 1 ms | 468 KB | correct |
31 | Correct | 1 ms | 468 KB | correct |
32 | Correct | 1 ms | 468 KB | correct |
33 | Correct | 1 ms | 468 KB | correct |
34 | Correct | 98 ms | 1124 KB | correct |
35 | Correct | 103 ms | 1176 KB | correct |
36 | Correct | 83 ms | 980 KB | correct |
37 | Correct | 15 ms | 584 KB | correct |
38 | Correct | 105 ms | 1192 KB | correct |
39 | Correct | 90 ms | 1116 KB | correct |
40 | Correct | 90 ms | 996 KB | correct |
41 | Correct | 113 ms | 1196 KB | correct |
42 | Correct | 97 ms | 1192 KB | correct |
43 | Correct | 54 ms | 900 KB | correct |
44 | Correct | 47 ms | 832 KB | correct |
45 | Correct | 54 ms | 880 KB | correct |
46 | Correct | 43 ms | 796 KB | correct |
47 | Correct | 23 ms | 596 KB | correct |
48 | Correct | 11 ms | 468 KB | correct |
49 | Correct | 14 ms | 584 KB | correct |
50 | Correct | 23 ms | 656 KB | correct |
51 | Correct | 52 ms | 884 KB | correct |
52 | Correct | 47 ms | 724 KB | correct |
53 | Correct | 43 ms | 724 KB | correct |
54 | Correct | 56 ms | 884 KB | correct |
55 | Correct | 54 ms | 880 KB | correct |
56 | Correct | 55 ms | 852 KB | correct |
57 | Correct | 55 ms | 884 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 1 ms | 468 KB | correct |
3 | Runtime error | 14 ms | 3448 KB | Execution killed with signal 11 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | correct |
2 | Correct | 1 ms | 432 KB | correct |
3 | Correct | 1 ms | 432 KB | correct |
4 | Correct | 1 ms | 468 KB | correct |
5 | Correct | 1 ms | 468 KB | correct |
6 | Correct | 1 ms | 468 KB | correct |
7 | Correct | 1 ms | 212 KB | correct |
8 | Correct | 1 ms | 468 KB | correct |
9 | Correct | 1 ms | 468 KB | correct |
10 | Correct | 1 ms | 524 KB | correct |
11 | Correct | 1 ms | 468 KB | correct |
12 | Correct | 1 ms | 468 KB | correct |
13 | Correct | 1 ms | 468 KB | correct |
14 | Correct | 2 ms | 440 KB | correct |
15 | Correct | 2 ms | 440 KB | correct |
16 | Correct | 2 ms | 468 KB | correct |
17 | Correct | 2 ms | 468 KB | correct |
18 | Correct | 1 ms | 468 KB | correct |
19 | Correct | 2 ms | 560 KB | correct |
20 | Correct | 2 ms | 440 KB | correct |
21 | Correct | 1 ms | 468 KB | correct |
22 | Correct | 1 ms | 468 KB | correct |
23 | Correct | 1 ms | 468 KB | correct |
24 | Correct | 1 ms | 468 KB | correct |
25 | Correct | 1 ms | 468 KB | correct |
26 | Correct | 1 ms | 436 KB | correct |
27 | Correct | 1 ms | 468 KB | correct |
28 | Correct | 1 ms | 468 KB | correct |
29 | Correct | 1 ms | 468 KB | correct |
30 | Correct | 1 ms | 468 KB | correct |
31 | Correct | 1 ms | 468 KB | correct |
32 | Correct | 1 ms | 468 KB | correct |
33 | Correct | 1 ms | 468 KB | correct |
34 | Correct | 98 ms | 1124 KB | correct |
35 | Correct | 103 ms | 1176 KB | correct |
36 | Correct | 83 ms | 980 KB | correct |
37 | Correct | 15 ms | 584 KB | correct |
38 | Correct | 105 ms | 1192 KB | correct |
39 | Correct | 90 ms | 1116 KB | correct |
40 | Correct | 90 ms | 996 KB | correct |
41 | Correct | 113 ms | 1196 KB | correct |
42 | Correct | 97 ms | 1192 KB | correct |
43 | Correct | 54 ms | 900 KB | correct |
44 | Correct | 47 ms | 832 KB | correct |
45 | Correct | 54 ms | 880 KB | correct |
46 | Correct | 43 ms | 796 KB | correct |
47 | Correct | 23 ms | 596 KB | correct |
48 | Correct | 11 ms | 468 KB | correct |
49 | Correct | 14 ms | 584 KB | correct |
50 | Correct | 23 ms | 656 KB | correct |
51 | Correct | 52 ms | 884 KB | correct |
52 | Correct | 47 ms | 724 KB | correct |
53 | Correct | 43 ms | 724 KB | correct |
54 | Correct | 56 ms | 884 KB | correct |
55 | Correct | 54 ms | 880 KB | correct |
56 | Correct | 55 ms | 852 KB | correct |
57 | Correct | 55 ms | 884 KB | correct |
58 | Correct | 1 ms | 212 KB | correct |
59 | Correct | 1 ms | 468 KB | correct |
60 | Runtime error | 14 ms | 3448 KB | Execution killed with signal 11 |
61 | Halted | 0 ms | 0 KB | - |