# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
95260 | 2019-01-29T07:03:03 Z | andy627 | Simurgh (IOI17_simurgh) | C++17 | 180 ms | 5340 KB |
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; int G[505][505]; int T[505][505]; int N; bool vst[505]; int E[505][505]; vector<int> Q; int P[505]; vector<int> ans; int S[505][505]; int I; bool C[505]; void maketree(int now) { vst[now] = true; for(int i = 0; i < N; i++) { if(vst[i]) continue; if(G[now][i] == -2) continue; T[now][i] = T[i][now] = 1; Q.push_back(E[now][i]); P[i] = now; maketree(i); } } void sib() { for(int i = 0; i < N; i++) { int now = i; while(now != -1) { S[now][i] = 1; now = P[now]; } } } /* void connect(int now, int par) { C[now] = 1; for(int i = 0; i < N; i++) { if(!T[now][i] || i == par) continue; if(G[now][i] == 1) connect(i, now); } }*/ void dfs(int now, int par) { for(int i = 0; i < N; i++) { if(i == par) continue; if(T[now][i]) dfs(i, now); } if(!now) return; int idx; for(int i = 0; i < Q.size(); i++) if(Q[i] == E[now][par]) idx = i; for(int i = 0; i < N; i++) { if(S[now][i] || i == par) continue; if(G[now][i] != -1) continue; Q[idx] = E[now][i]; int tmp = count_common_roads(Q); if(tmp < I) { G[now][par] = G[par][now] = 1; G[now][i] = G[i][now] = 0; } if(tmp > I) { G[now][par] = G[par][now] = 0; G[now][i] = G[i][now] = 1; } } Q[idx] = E[now][par]; for(int i = 0; i < N; i++) { if(S[now][i] || i == par) continue; if(G[now][i] == -1) G[now][i] = G[i][now] = G[now][par]; } if(G[now][par] == -1) { //for(int i = 0; i < N; i++) C[i] = 0; //connect(now, par); int x = -1, y = -1; for(int i = 0; i < N; i++) { if(!S[now][i] || i == now) continue; for(int j = 0; j < N; j++) { if(S[now][j] || G[i][j] != 1) continue; x = i, y = j; } } //printf("%d %d\n", x,y); if(x == -1) G[now][par] = G[par][now] = 1; else { Q[idx] = E[x][y]; int tmp = count_common_roads(Q); if(tmp < I) G[now][par] = G[par][now] = 1; else if(tmp > I) G[now][par] = G[par][now] = 0; else G[now][par] = G[par][now] = G[x][y]; Q[idx] = E[now][par]; } for(int i = 0; i < N; i++) { if(S[now][i] || i == par) continue; if(G[now][i] == -1) G[now][i] = G[i][now] = G[now][par]; } } } std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { N = n; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { G[i][j] = -2; } } for(int i = 0; i < u.size(); i++) { G[u[i]][v[i]] = G[v[i]][u[i]] = -1; E[u[i]][v[i]] = E[v[i]][u[i]] = i; } P[0] = -1; maketree(0); sib(); I = count_common_roads(Q); dfs(0, -1); /* for(int i = 0; i < N; i++){ for(int j = 0; j < N;j++) { printf("%d ", G[i][j]); } puts(""); }*/ for(int i = 0; i < N; i++) { for(int j = i + 1; j < N; j++) { if(G[i][j] == 1) ans.push_back(E[i][j]); } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | correct |
2 | Correct | 2 ms | 504 KB | correct |
3 | Correct | 2 ms | 376 KB | correct |
4 | Correct | 2 ms | 376 KB | correct |
5 | Correct | 2 ms | 376 KB | correct |
6 | Correct | 2 ms | 380 KB | correct |
7 | Correct | 2 ms | 376 KB | correct |
8 | Correct | 2 ms | 376 KB | correct |
9 | Correct | 2 ms | 376 KB | correct |
10 | Correct | 2 ms | 376 KB | correct |
11 | Correct | 2 ms | 376 KB | correct |
12 | Correct | 2 ms | 376 KB | correct |
13 | Correct | 2 ms | 376 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | correct |
2 | Correct | 2 ms | 504 KB | correct |
3 | Correct | 2 ms | 376 KB | correct |
4 | Correct | 2 ms | 376 KB | correct |
5 | Correct | 2 ms | 376 KB | correct |
6 | Correct | 2 ms | 380 KB | correct |
7 | Correct | 2 ms | 376 KB | correct |
8 | Correct | 2 ms | 376 KB | correct |
9 | Correct | 2 ms | 376 KB | correct |
10 | Correct | 2 ms | 376 KB | correct |
11 | Correct | 2 ms | 376 KB | correct |
12 | Correct | 2 ms | 376 KB | correct |
13 | Correct | 2 ms | 376 KB | correct |
14 | Correct | 3 ms | 760 KB | correct |
15 | Correct | 3 ms | 760 KB | correct |
16 | Correct | 3 ms | 760 KB | correct |
17 | Correct | 3 ms | 764 KB | correct |
18 | Correct | 2 ms | 760 KB | correct |
19 | Correct | 3 ms | 760 KB | correct |
20 | Correct | 3 ms | 760 KB | correct |
21 | Correct | 3 ms | 760 KB | correct |
22 | Correct | 3 ms | 760 KB | correct |
23 | Correct | 2 ms | 760 KB | correct |
24 | Correct | 3 ms | 760 KB | correct |
25 | Correct | 2 ms | 760 KB | correct |
26 | Correct | 3 ms | 760 KB | correct |
27 | Correct | 3 ms | 760 KB | correct |
28 | Correct | 2 ms | 760 KB | correct |
29 | Correct | 2 ms | 760 KB | correct |
30 | Correct | 2 ms | 760 KB | correct |
31 | Correct | 2 ms | 764 KB | correct |
32 | Correct | 2 ms | 760 KB | correct |
33 | Correct | 2 ms | 760 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | correct |
2 | Correct | 2 ms | 504 KB | correct |
3 | Correct | 2 ms | 376 KB | correct |
4 | Correct | 2 ms | 376 KB | correct |
5 | Correct | 2 ms | 376 KB | correct |
6 | Correct | 2 ms | 380 KB | correct |
7 | Correct | 2 ms | 376 KB | correct |
8 | Correct | 2 ms | 376 KB | correct |
9 | Correct | 2 ms | 376 KB | correct |
10 | Correct | 2 ms | 376 KB | correct |
11 | Correct | 2 ms | 376 KB | correct |
12 | Correct | 2 ms | 376 KB | correct |
13 | Correct | 2 ms | 376 KB | correct |
14 | Correct | 3 ms | 760 KB | correct |
15 | Correct | 3 ms | 760 KB | correct |
16 | Correct | 3 ms | 760 KB | correct |
17 | Correct | 3 ms | 764 KB | correct |
18 | Correct | 2 ms | 760 KB | correct |
19 | Correct | 3 ms | 760 KB | correct |
20 | Correct | 3 ms | 760 KB | correct |
21 | Correct | 3 ms | 760 KB | correct |
22 | Correct | 3 ms | 760 KB | correct |
23 | Correct | 2 ms | 760 KB | correct |
24 | Correct | 3 ms | 760 KB | correct |
25 | Correct | 2 ms | 760 KB | correct |
26 | Correct | 3 ms | 760 KB | correct |
27 | Correct | 3 ms | 760 KB | correct |
28 | Correct | 2 ms | 760 KB | correct |
29 | Correct | 2 ms | 760 KB | correct |
30 | Correct | 2 ms | 760 KB | correct |
31 | Correct | 2 ms | 764 KB | correct |
32 | Correct | 2 ms | 760 KB | correct |
33 | Correct | 2 ms | 760 KB | correct |
34 | Correct | 180 ms | 3064 KB | correct |
35 | Correct | 87 ms | 2808 KB | correct |
36 | Correct | 62 ms | 2680 KB | correct |
37 | Correct | 11 ms | 2296 KB | correct |
38 | Correct | 96 ms | 2944 KB | correct |
39 | Correct | 82 ms | 2844 KB | correct |
40 | Correct | 64 ms | 2680 KB | correct |
41 | Correct | 99 ms | 2940 KB | correct |
42 | Correct | 94 ms | 2932 KB | correct |
43 | Correct | 52 ms | 2680 KB | correct |
44 | Correct | 43 ms | 2552 KB | correct |
45 | Correct | 49 ms | 2552 KB | correct |
46 | Correct | 39 ms | 2552 KB | correct |
47 | Correct | 19 ms | 2424 KB | correct |
48 | Correct | 6 ms | 2296 KB | correct |
49 | Correct | 10 ms | 2296 KB | correct |
50 | Correct | 21 ms | 2552 KB | correct |
51 | Correct | 52 ms | 2556 KB | correct |
52 | Correct | 43 ms | 2556 KB | correct |
53 | Correct | 39 ms | 2424 KB | correct |
54 | Correct | 52 ms | 2552 KB | correct |
55 | Correct | 48 ms | 2552 KB | correct |
56 | Correct | 49 ms | 2552 KB | correct |
57 | Correct | 48 ms | 2680 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | correct |
2 | Correct | 2 ms | 376 KB | correct |
3 | Incorrect | 78 ms | 5340 KB | WA in grader: NO |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | correct |
2 | Correct | 2 ms | 504 KB | correct |
3 | Correct | 2 ms | 376 KB | correct |
4 | Correct | 2 ms | 376 KB | correct |
5 | Correct | 2 ms | 376 KB | correct |
6 | Correct | 2 ms | 380 KB | correct |
7 | Correct | 2 ms | 376 KB | correct |
8 | Correct | 2 ms | 376 KB | correct |
9 | Correct | 2 ms | 376 KB | correct |
10 | Correct | 2 ms | 376 KB | correct |
11 | Correct | 2 ms | 376 KB | correct |
12 | Correct | 2 ms | 376 KB | correct |
13 | Correct | 2 ms | 376 KB | correct |
14 | Correct | 3 ms | 760 KB | correct |
15 | Correct | 3 ms | 760 KB | correct |
16 | Correct | 3 ms | 760 KB | correct |
17 | Correct | 3 ms | 764 KB | correct |
18 | Correct | 2 ms | 760 KB | correct |
19 | Correct | 3 ms | 760 KB | correct |
20 | Correct | 3 ms | 760 KB | correct |
21 | Correct | 3 ms | 760 KB | correct |
22 | Correct | 3 ms | 760 KB | correct |
23 | Correct | 2 ms | 760 KB | correct |
24 | Correct | 3 ms | 760 KB | correct |
25 | Correct | 2 ms | 760 KB | correct |
26 | Correct | 3 ms | 760 KB | correct |
27 | Correct | 3 ms | 760 KB | correct |
28 | Correct | 2 ms | 760 KB | correct |
29 | Correct | 2 ms | 760 KB | correct |
30 | Correct | 2 ms | 760 KB | correct |
31 | Correct | 2 ms | 764 KB | correct |
32 | Correct | 2 ms | 760 KB | correct |
33 | Correct | 2 ms | 760 KB | correct |
34 | Correct | 180 ms | 3064 KB | correct |
35 | Correct | 87 ms | 2808 KB | correct |
36 | Correct | 62 ms | 2680 KB | correct |
37 | Correct | 11 ms | 2296 KB | correct |
38 | Correct | 96 ms | 2944 KB | correct |
39 | Correct | 82 ms | 2844 KB | correct |
40 | Correct | 64 ms | 2680 KB | correct |
41 | Correct | 99 ms | 2940 KB | correct |
42 | Correct | 94 ms | 2932 KB | correct |
43 | Correct | 52 ms | 2680 KB | correct |
44 | Correct | 43 ms | 2552 KB | correct |
45 | Correct | 49 ms | 2552 KB | correct |
46 | Correct | 39 ms | 2552 KB | correct |
47 | Correct | 19 ms | 2424 KB | correct |
48 | Correct | 6 ms | 2296 KB | correct |
49 | Correct | 10 ms | 2296 KB | correct |
50 | Correct | 21 ms | 2552 KB | correct |
51 | Correct | 52 ms | 2556 KB | correct |
52 | Correct | 43 ms | 2556 KB | correct |
53 | Correct | 39 ms | 2424 KB | correct |
54 | Correct | 52 ms | 2552 KB | correct |
55 | Correct | 48 ms | 2552 KB | correct |
56 | Correct | 49 ms | 2552 KB | correct |
57 | Correct | 48 ms | 2680 KB | correct |
58 | Correct | 2 ms | 376 KB | correct |
59 | Correct | 2 ms | 376 KB | correct |
60 | Incorrect | 78 ms | 5340 KB | WA in grader: NO |
61 | Halted | 0 ms | 0 KB | - |