# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
807388 | 2023-08-04T16:37:15 Z | nemethm | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 150 ms | 27952 KB |
#include "supertrees.h" #include <vector> using namespace std; int cmp[1010] = {0}; int subtask3(std::vector<std::vector<int>> p){ int n = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } int id = 0; vector<vector<int>> elek; for(int i = 0; i < n; ++i){ bool uj = false; if(cmp[i] == 0){ ++id; cmp[i] = id; uj = true; elek.push_back({i}); } for(int j = 0; j < n; ++j){ if(j == i) continue; if(p[i][j] == 2){ if(cmp[j] != cmp[i] && !uj){ return 0; } else if(uj){ cmp[j] = cmp[i]; elek.back().push_back(j); } } else{ if(cmp[j] == cmp[i]){ return 0; } } } } for(auto& v : elek){ if(v.size() == 2){ return 0; } if(v.size() > 2){ for(int i = 0; i < v.size(); ++i){ answer[v[i]][v[(i + 1) % v.size()]] = answer[v[(i + 1) % v.size()]][v[i]] = 1; } } } build(answer); return 1; } int subtask12(std::vector<std::vector<int>> p){ int n = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } int id = 0; vector<vector<pair<int,int>>> elek; for(int i = 0; i < n; ++i){ bool uj = false; if(cmp[i] == 0){ ++id; cmp[i] = id; uj = true; elek.push_back({}); } for(int j = 0; j < n; ++j){ if(j == i) continue; if(p[i][j] == 1){ if(cmp[j] != cmp[i] && !uj){ return 0; } else if(uj){ cmp[j] = cmp[i]; elek.back().push_back({j, i}); } } else{ if(cmp[j] == cmp[i]){ return 0; } } } } for(auto& v : elek){ for(auto i : v){ answer[i.first][i.second] = answer[i.second][i.first] = 1; } } build(answer); return 1; } int construct(std::vector<std::vector<int>> p) { for(int i = 0; i < p.size(); ++i){ for(int j = 0; j < p.size(); ++j){ if(p[i][j] == 2){ return subtask3(p); } } } return subtask12(p); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1364 KB | Output is correct |
7 | Correct | 137 ms | 25980 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1364 KB | Output is correct |
7 | Correct | 137 ms | 25980 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 6 ms | 1236 KB | Output is correct |
13 | Correct | 134 ms | 25976 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 63 ms | 15992 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 34 ms | 6660 KB | Output is correct |
21 | Correct | 137 ms | 25932 KB | Output is correct |
22 | Correct | 141 ms | 25996 KB | Output is correct |
23 | Correct | 142 ms | 25908 KB | Output is correct |
24 | Correct | 134 ms | 25980 KB | Output is correct |
25 | Correct | 62 ms | 16008 KB | Output is correct |
26 | Correct | 60 ms | 15996 KB | Output is correct |
27 | Correct | 140 ms | 25912 KB | Output is correct |
28 | Correct | 141 ms | 25960 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 6 ms | 1328 KB | Output is correct |
9 | Correct | 134 ms | 27952 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 6 ms | 1364 KB | Output is correct |
13 | Correct | 145 ms | 27888 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 980 KB | Output is correct |
17 | Correct | 64 ms | 18048 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 34 ms | 7200 KB | Output is correct |
22 | Correct | 137 ms | 27932 KB | Output is correct |
23 | Correct | 137 ms | 27892 KB | Output is correct |
24 | Correct | 138 ms | 27888 KB | Output is correct |
25 | Correct | 62 ms | 18044 KB | Output is correct |
26 | Correct | 60 ms | 17996 KB | Output is correct |
27 | Correct | 134 ms | 27900 KB | Output is correct |
28 | Correct | 148 ms | 27852 KB | Output is correct |
29 | Correct | 63 ms | 18028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 35 ms | 7208 KB | Output is correct |
5 | Correct | 141 ms | 27900 KB | Output is correct |
6 | Correct | 140 ms | 27924 KB | Output is correct |
7 | Correct | 142 ms | 27896 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 40 ms | 7180 KB | Output is correct |
10 | Correct | 150 ms | 27896 KB | Output is correct |
11 | Correct | 132 ms | 27892 KB | Output is correct |
12 | Correct | 145 ms | 27884 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Incorrect | 0 ms | 212 KB | Too few ways to get from 4 to 5, should be 1 found 0 |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1364 KB | Output is correct |
7 | Correct | 137 ms | 25980 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 6 ms | 1236 KB | Output is correct |
13 | Correct | 134 ms | 25976 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 63 ms | 15992 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 34 ms | 6660 KB | Output is correct |
21 | Correct | 137 ms | 25932 KB | Output is correct |
22 | Correct | 141 ms | 25996 KB | Output is correct |
23 | Correct | 142 ms | 25908 KB | Output is correct |
24 | Correct | 134 ms | 25980 KB | Output is correct |
25 | Correct | 62 ms | 16008 KB | Output is correct |
26 | Correct | 60 ms | 15996 KB | Output is correct |
27 | Correct | 140 ms | 25912 KB | Output is correct |
28 | Correct | 141 ms | 25960 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 0 ms | 212 KB | Output is correct |
36 | Correct | 6 ms | 1328 KB | Output is correct |
37 | Correct | 134 ms | 27952 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 6 ms | 1364 KB | Output is correct |
41 | Correct | 145 ms | 27888 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 3 ms | 980 KB | Output is correct |
45 | Correct | 64 ms | 18048 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 212 KB | Output is correct |
48 | Correct | 0 ms | 212 KB | Output is correct |
49 | Correct | 34 ms | 7200 KB | Output is correct |
50 | Correct | 137 ms | 27932 KB | Output is correct |
51 | Correct | 137 ms | 27892 KB | Output is correct |
52 | Correct | 138 ms | 27888 KB | Output is correct |
53 | Correct | 62 ms | 18044 KB | Output is correct |
54 | Correct | 60 ms | 17996 KB | Output is correct |
55 | Correct | 134 ms | 27900 KB | Output is correct |
56 | Correct | 148 ms | 27852 KB | Output is correct |
57 | Correct | 63 ms | 18028 KB | Output is correct |
58 | Correct | 0 ms | 212 KB | Output is correct |
59 | Correct | 1 ms | 288 KB | Output is correct |
60 | Correct | 3 ms | 980 KB | Output is correct |
61 | Correct | 63 ms | 18032 KB | Output is correct |
62 | Correct | 0 ms | 212 KB | Output is correct |
63 | Incorrect | 1 ms | 212 KB | Too few ways to get from 0 to 1, should be 1 found 0 |
64 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1364 KB | Output is correct |
7 | Correct | 137 ms | 25980 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 6 ms | 1236 KB | Output is correct |
13 | Correct | 134 ms | 25976 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 63 ms | 15992 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 34 ms | 6660 KB | Output is correct |
21 | Correct | 137 ms | 25932 KB | Output is correct |
22 | Correct | 141 ms | 25996 KB | Output is correct |
23 | Correct | 142 ms | 25908 KB | Output is correct |
24 | Correct | 134 ms | 25980 KB | Output is correct |
25 | Correct | 62 ms | 16008 KB | Output is correct |
26 | Correct | 60 ms | 15996 KB | Output is correct |
27 | Correct | 140 ms | 25912 KB | Output is correct |
28 | Correct | 141 ms | 25960 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 0 ms | 212 KB | Output is correct |
36 | Correct | 6 ms | 1328 KB | Output is correct |
37 | Correct | 134 ms | 27952 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 6 ms | 1364 KB | Output is correct |
41 | Correct | 145 ms | 27888 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 3 ms | 980 KB | Output is correct |
45 | Correct | 64 ms | 18048 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 212 KB | Output is correct |
48 | Correct | 0 ms | 212 KB | Output is correct |
49 | Correct | 34 ms | 7200 KB | Output is correct |
50 | Correct | 137 ms | 27932 KB | Output is correct |
51 | Correct | 137 ms | 27892 KB | Output is correct |
52 | Correct | 138 ms | 27888 KB | Output is correct |
53 | Correct | 62 ms | 18044 KB | Output is correct |
54 | Correct | 60 ms | 17996 KB | Output is correct |
55 | Correct | 134 ms | 27900 KB | Output is correct |
56 | Correct | 148 ms | 27852 KB | Output is correct |
57 | Correct | 63 ms | 18028 KB | Output is correct |
58 | Correct | 0 ms | 212 KB | Output is correct |
59 | Correct | 0 ms | 212 KB | Output is correct |
60 | Correct | 1 ms | 212 KB | Output is correct |
61 | Correct | 35 ms | 7208 KB | Output is correct |
62 | Correct | 141 ms | 27900 KB | Output is correct |
63 | Correct | 140 ms | 27924 KB | Output is correct |
64 | Correct | 142 ms | 27896 KB | Output is correct |
65 | Correct | 1 ms | 212 KB | Output is correct |
66 | Correct | 40 ms | 7180 KB | Output is correct |
67 | Correct | 150 ms | 27896 KB | Output is correct |
68 | Correct | 132 ms | 27892 KB | Output is correct |
69 | Correct | 145 ms | 27884 KB | Output is correct |
70 | Correct | 0 ms | 212 KB | Output is correct |
71 | Incorrect | 0 ms | 212 KB | Too few ways to get from 4 to 5, should be 1 found 0 |
72 | Halted | 0 ms | 0 KB | - |