# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
301447 | 2020-09-18T01:00:29 Z | qpwoeirut | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 281 ms | 22264 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; typedef vector<vector<int>> vvi; const int MN = 1001; int N; int root[MN]; int par(int u) { if (u == root[u]) return u; root[u] = par(root[u]); return root[u]; } void join(int u, int v) { int ru = par(u), rv = par(v); if (ru == rv) return; root[ru] = rv; } bool dsu(const vvi& p) { for (int i=0; i<N; ++i) { root[i] = i; } for (int i=0; i<N; ++i) { for (int j=0; j<N; ++j) { if (p[i][j]) join(i, j); } } for (int i=0; i<N; ++i) { for (int j=0; j<N; ++j) { if (par(i) == par(j) && p[i][j] == 0) { return 0; } } } return 1; } int sub2(const vvi& p) { if (!dsu(p)) return 0; vvi ans(N, vector<int>(N)); for (int i=0; i<N; ++i) { if (i != par(i)) { ans[i][par(i)] = true; ans[par(i)][i] = true; } for (int j=0; j<N; ++j) assert(p[i][j] < 2); } build(ans); return 1; } int sub3(const vvi& p) { if (!dsu(p)) return 0; vvi ans(N, vector<int>(N)); vvi groups; for (int i=0; i<N; ++i) { if (i == par(i)) { vector<int> cur; for (int j=0; j<N; ++j) { if (i == par(j)) { cur.push_back(j); } assert(p[i][j] < 3); } groups.push_back(cur); } } for (int i=0; i<groups.size(); ++i) { int gsz = groups[i].size(); if (gsz == 1) continue; if (gsz == 2) return 0; for (int j=0; j<gsz; ++j) { ans[groups[i][(j+1) % gsz]][groups[i][j]] = ans[groups[i][j]][groups[i][(j+1) % gsz]] = 1; } } build(ans); return 1; } int construct(std::vector<std::vector<int>> p) { N = p.size(); set<int> vals; for (int i=0; i<N; ++i) { for (int j=0; j<N; ++j) { vals.insert(p[i][j]); } } if ((vals.size() == 1 && vals.count(1)) || (vals.size() == 2 && vals.count(0) && vals.count(1))) { return sub2(p); } if (vals.count(2)) { return sub3(p); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 11 ms | 1152 KB | Output is correct |
7 | Correct | 256 ms | 22136 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 11 ms | 1152 KB | Output is correct |
7 | Correct | 256 ms | 22136 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 10 ms | 1152 KB | Output is correct |
13 | Correct | 239 ms | 22140 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 6 ms | 640 KB | Output is correct |
17 | Correct | 122 ms | 8184 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 61 ms | 5752 KB | Output is correct |
21 | Correct | 251 ms | 22140 KB | Output is correct |
22 | Correct | 244 ms | 22140 KB | Output is correct |
23 | Correct | 281 ms | 22136 KB | Output is correct |
24 | Correct | 238 ms | 22136 KB | Output is correct |
25 | Correct | 100 ms | 8280 KB | Output is correct |
26 | Correct | 96 ms | 8184 KB | Output is correct |
27 | Correct | 278 ms | 22136 KB | Output is correct |
28 | Correct | 244 ms | 22136 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 1 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 10 ms | 1152 KB | Output is correct |
9 | Correct | 237 ms | 22140 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 12 ms | 1152 KB | Output is correct |
13 | Correct | 270 ms | 22112 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 5 ms | 640 KB | Output is correct |
17 | Correct | 124 ms | 8184 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |
21 | Correct | 62 ms | 5880 KB | Output is correct |
22 | Correct | 247 ms | 22136 KB | Output is correct |
23 | Correct | 243 ms | 22136 KB | Output is correct |
24 | Correct | 272 ms | 22108 KB | Output is correct |
25 | Correct | 105 ms | 12152 KB | Output is correct |
26 | Correct | 102 ms | 8184 KB | Output is correct |
27 | Correct | 242 ms | 22136 KB | Output is correct |
28 | Correct | 274 ms | 22252 KB | Output is correct |
29 | Correct | 106 ms | 12280 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 67 ms | 5956 KB | Output is correct |
5 | Correct | 247 ms | 22136 KB | Output is correct |
6 | Correct | 242 ms | 22136 KB | Output is correct |
7 | Correct | 275 ms | 22136 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 61 ms | 5752 KB | Output is correct |
10 | Correct | 253 ms | 22232 KB | Output is correct |
11 | Correct | 249 ms | 22264 KB | Output is correct |
12 | Correct | 279 ms | 22244 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
14 | Incorrect | 0 ms | 256 KB | Too many ways to get from 4 to 8, should be 1 found no less than 2 |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 11 ms | 1152 KB | Output is correct |
7 | Correct | 256 ms | 22136 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 10 ms | 1152 KB | Output is correct |
13 | Correct | 239 ms | 22140 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 6 ms | 640 KB | Output is correct |
17 | Correct | 122 ms | 8184 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 61 ms | 5752 KB | Output is correct |
21 | Correct | 251 ms | 22140 KB | Output is correct |
22 | Correct | 244 ms | 22140 KB | Output is correct |
23 | Correct | 281 ms | 22136 KB | Output is correct |
24 | Correct | 238 ms | 22136 KB | Output is correct |
25 | Correct | 100 ms | 8280 KB | Output is correct |
26 | Correct | 96 ms | 8184 KB | Output is correct |
27 | Correct | 278 ms | 22136 KB | Output is correct |
28 | Correct | 244 ms | 22136 KB | Output is correct |
29 | Correct | 1 ms | 256 KB | Output is correct |
30 | Correct | 0 ms | 256 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Correct | 0 ms | 256 KB | Output is correct |
33 | Correct | 1 ms | 256 KB | Output is correct |
34 | Correct | 1 ms | 256 KB | Output is correct |
35 | Correct | 1 ms | 256 KB | Output is correct |
36 | Correct | 10 ms | 1152 KB | Output is correct |
37 | Correct | 237 ms | 22140 KB | Output is correct |
38 | Correct | 1 ms | 256 KB | Output is correct |
39 | Correct | 1 ms | 256 KB | Output is correct |
40 | Correct | 12 ms | 1152 KB | Output is correct |
41 | Correct | 270 ms | 22112 KB | Output is correct |
42 | Correct | 0 ms | 256 KB | Output is correct |
43 | Correct | 0 ms | 256 KB | Output is correct |
44 | Correct | 5 ms | 640 KB | Output is correct |
45 | Correct | 124 ms | 8184 KB | Output is correct |
46 | Correct | 0 ms | 256 KB | Output is correct |
47 | Correct | 0 ms | 256 KB | Output is correct |
48 | Correct | 0 ms | 256 KB | Output is correct |
49 | Correct | 62 ms | 5880 KB | Output is correct |
50 | Correct | 247 ms | 22136 KB | Output is correct |
51 | Correct | 243 ms | 22136 KB | Output is correct |
52 | Correct | 272 ms | 22108 KB | Output is correct |
53 | Correct | 105 ms | 12152 KB | Output is correct |
54 | Correct | 102 ms | 8184 KB | Output is correct |
55 | Correct | 242 ms | 22136 KB | Output is correct |
56 | Correct | 274 ms | 22252 KB | Output is correct |
57 | Correct | 106 ms | 12280 KB | Output is correct |
58 | Correct | 0 ms | 256 KB | Output is correct |
59 | Correct | 0 ms | 256 KB | Output is correct |
60 | Correct | 6 ms | 640 KB | Output is correct |
61 | Correct | 128 ms | 8184 KB | Output is correct |
62 | Correct | 0 ms | 256 KB | Output is correct |
63 | Incorrect | 0 ms | 256 KB | Too many ways to get from 0 to 9, should be 1 found no less than 2 |
64 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 11 ms | 1152 KB | Output is correct |
7 | Correct | 256 ms | 22136 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 10 ms | 1152 KB | Output is correct |
13 | Correct | 239 ms | 22140 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 6 ms | 640 KB | Output is correct |
17 | Correct | 122 ms | 8184 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 61 ms | 5752 KB | Output is correct |
21 | Correct | 251 ms | 22140 KB | Output is correct |
22 | Correct | 244 ms | 22140 KB | Output is correct |
23 | Correct | 281 ms | 22136 KB | Output is correct |
24 | Correct | 238 ms | 22136 KB | Output is correct |
25 | Correct | 100 ms | 8280 KB | Output is correct |
26 | Correct | 96 ms | 8184 KB | Output is correct |
27 | Correct | 278 ms | 22136 KB | Output is correct |
28 | Correct | 244 ms | 22136 KB | Output is correct |
29 | Correct | 1 ms | 256 KB | Output is correct |
30 | Correct | 0 ms | 256 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Correct | 0 ms | 256 KB | Output is correct |
33 | Correct | 1 ms | 256 KB | Output is correct |
34 | Correct | 1 ms | 256 KB | Output is correct |
35 | Correct | 1 ms | 256 KB | Output is correct |
36 | Correct | 10 ms | 1152 KB | Output is correct |
37 | Correct | 237 ms | 22140 KB | Output is correct |
38 | Correct | 1 ms | 256 KB | Output is correct |
39 | Correct | 1 ms | 256 KB | Output is correct |
40 | Correct | 12 ms | 1152 KB | Output is correct |
41 | Correct | 270 ms | 22112 KB | Output is correct |
42 | Correct | 0 ms | 256 KB | Output is correct |
43 | Correct | 0 ms | 256 KB | Output is correct |
44 | Correct | 5 ms | 640 KB | Output is correct |
45 | Correct | 124 ms | 8184 KB | Output is correct |
46 | Correct | 0 ms | 256 KB | Output is correct |
47 | Correct | 0 ms | 256 KB | Output is correct |
48 | Correct | 0 ms | 256 KB | Output is correct |
49 | Correct | 62 ms | 5880 KB | Output is correct |
50 | Correct | 247 ms | 22136 KB | Output is correct |
51 | Correct | 243 ms | 22136 KB | Output is correct |
52 | Correct | 272 ms | 22108 KB | Output is correct |
53 | Correct | 105 ms | 12152 KB | Output is correct |
54 | Correct | 102 ms | 8184 KB | Output is correct |
55 | Correct | 242 ms | 22136 KB | Output is correct |
56 | Correct | 274 ms | 22252 KB | Output is correct |
57 | Correct | 106 ms | 12280 KB | Output is correct |
58 | Correct | 1 ms | 256 KB | Output is correct |
59 | Correct | 0 ms | 256 KB | Output is correct |
60 | Correct | 0 ms | 256 KB | Output is correct |
61 | Correct | 67 ms | 5956 KB | Output is correct |
62 | Correct | 247 ms | 22136 KB | Output is correct |
63 | Correct | 242 ms | 22136 KB | Output is correct |
64 | Correct | 275 ms | 22136 KB | Output is correct |
65 | Correct | 0 ms | 256 KB | Output is correct |
66 | Correct | 61 ms | 5752 KB | Output is correct |
67 | Correct | 253 ms | 22232 KB | Output is correct |
68 | Correct | 249 ms | 22264 KB | Output is correct |
69 | Correct | 279 ms | 22244 KB | Output is correct |
70 | Correct | 1 ms | 256 KB | Output is correct |
71 | Incorrect | 0 ms | 256 KB | Too many ways to get from 4 to 8, should be 1 found no less than 2 |
72 | Halted | 0 ms | 0 KB | - |