# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1079269 | 2024-08-28T12:29:23 Z | Jawad_Akbar_JJ | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 155 ms | 22248 KB |
#include <iostream> #include <vector> #include <algorithm> #include "supertrees.h" using namespace std; const int NN = 1005; int seen[NN]; int construct(vector<vector<int>> p){ int n = p.size(); vector<vector<int>> ans(n, vector<int> (n, 0)), comp, comp2; vector<int> out; int z = 0, o = 0, t = 0, th = 0; for (int i=0;i<n;i++) for (int j=0;j<n;j++){ z += p[i][j] == 0; o += p[i][j] == 1; t += p[i][j] == 2; th += p[i][j] == 3; } if (o and z + t + th == 0){ for (int i=1;i<n;i++) ans[i-1][i] = ans[i][i-1] = 1; build(ans); return 1; } if (t + th == 0){ for (int i=0;i<n;i++){ int mx = 0, ind = -1; for (int k=0;k<comp.size();k++){ int cnt = 0; for (int j : comp[k]) cnt += p[i][j]; if (cnt == 0) continue; if (mx > 0 or cnt != comp[k].size()) return 0; ind = k; mx = cnt; } if (ind == -1) comp.push_back({i}); else comp[ind].push_back(i); } for (auto v : comp) for (int j=1;j<v.size();j++) ans[v[j-1]][v[j]] = ans[v[j]][v[j-1]] = 1; build(ans); return 1; } if (o == n and th == 0){ for (int i=0;i<n;i++){ int mx = 0, ind = -1; for (int k=0;k<comp.size();k++){ int cnt = 0; for (int j : comp[k]) cnt += p[i][j] == 2; if (cnt == 0) continue; if (mx > 0 or cnt != comp[k].size()) return 0; ind = k; mx = cnt; } if (ind == -1) comp.push_back({i}); else comp[ind].push_back(i); } for (auto v : comp){ for (int j=1;j<v.size();j++) ans[v[j-1]][v[j]] = ans[v[j]][v[j-1]] = 1; if (v.size() > 1) ans[v.back()][v[0]] = ans[v[0]][v.back()] = 1; if (v.size() == 2) return 0; } build(ans); return 1; } vector<pair<int,int>> vec; if (th == 0){ for (int i=0;i<n;i++){ int mx = 0, ind = -1; for (int k=0;k<comp.size();k++){ int cnt = 0; for (int j : comp[k]) cnt += p[i][j] == 2; if (cnt == 0) continue; if (cnt == comp[k].size()){ ind = k; mx = cnt; } } if (ind == -1) comp.push_back({i}); else comp[ind].push_back(i); } for (int i=0;i<comp.size();i++) vec.push_back({comp[i].size(), i}); sort(begin(vec), end(vec)); for (auto [sz, idx] : vec){ vector<int> v = comp[idx]; if (v.size() > 2){ bool poss = 1; for (int i : v){ if (seen[i]) poss = 0; seen[i] = 1; } if (!poss) continue; for (int j=1;j<v.size();j++) ans[v[j-1]][v[j]] = ans[v[j]][v[j-1]] = 1; ans[v.back()][v[0]] = ans[v[0]][v.back()] = 1; for (int i : v){ for (int j=0;j<n;j++) if (i != j and p[i][j] == 1 and !seen[j]) ans[i][j] = ans[j][i] = seen[j] = 1; } } } comp.clear(); for (int i=0;i<n;i++){ if (seen[i]) continue; int mx = 0, ind = -1; for (int k=0;k<comp.size();k++){ int cnt = 0; for (int j : comp[k]) cnt += p[i][j] == 1; if (cnt == 0) continue; if (cnt == comp[k].size()){ ind = k; mx = cnt; } } if (ind == -1) comp.push_back({i}); else comp[ind].push_back(i); } for (auto v : comp){ for (int j=1;j<v.size();j++) ans[v[j-1]][v[j]] = ans[v[j]][v[j-1]] = 1; } build(ans); return 1; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 1116 KB | Output is correct |
7 | Correct | 119 ms | 22100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 1116 KB | Output is correct |
7 | Correct | 119 ms | 22100 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 1116 KB | Output is correct |
13 | Correct | 116 ms | 22100 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 55 ms | 12112 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 32 ms | 5712 KB | Output is correct |
21 | Correct | 116 ms | 22040 KB | Output is correct |
22 | Correct | 116 ms | 22100 KB | Output is correct |
23 | Correct | 127 ms | 22040 KB | Output is correct |
24 | Correct | 113 ms | 22044 KB | Output is correct |
25 | Correct | 50 ms | 12280 KB | Output is correct |
26 | Correct | 49 ms | 12112 KB | Output is correct |
27 | Correct | 123 ms | 22024 KB | Output is correct |
28 | Correct | 113 ms | 22100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 5 ms | 1116 KB | Output is correct |
9 | Correct | 132 ms | 22096 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 11 ms | 1116 KB | Output is correct |
13 | Correct | 134 ms | 22248 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 860 KB | Output is correct |
17 | Correct | 59 ms | 12056 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 62 ms | 5808 KB | Output is correct |
22 | Correct | 117 ms | 22044 KB | Output is correct |
23 | Correct | 123 ms | 22100 KB | Output is correct |
24 | Correct | 155 ms | 22080 KB | Output is correct |
25 | Correct | 57 ms | 12112 KB | Output is correct |
26 | Correct | 56 ms | 12040 KB | Output is correct |
27 | Correct | 130 ms | 22044 KB | Output is correct |
28 | Correct | 143 ms | 22040 KB | Output is correct |
29 | Correct | 53 ms | 12312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 40 ms | 5896 KB | Output is correct |
5 | Correct | 128 ms | 22024 KB | Output is correct |
6 | Correct | 122 ms | 22136 KB | Output is correct |
7 | Correct | 122 ms | 22044 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 28 ms | 5692 KB | Output is correct |
10 | Correct | 138 ms | 22096 KB | Output is correct |
11 | Correct | 144 ms | 22028 KB | Output is correct |
12 | Correct | 122 ms | 22096 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Incorrect | 0 ms | 348 KB | Too few ways to get from 0 to 1, should be 2 found 0 |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 1116 KB | Output is correct |
7 | Correct | 119 ms | 22100 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 1116 KB | Output is correct |
13 | Correct | 116 ms | 22100 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 55 ms | 12112 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 32 ms | 5712 KB | Output is correct |
21 | Correct | 116 ms | 22040 KB | Output is correct |
22 | Correct | 116 ms | 22100 KB | Output is correct |
23 | Correct | 127 ms | 22040 KB | Output is correct |
24 | Correct | 113 ms | 22044 KB | Output is correct |
25 | Correct | 50 ms | 12280 KB | Output is correct |
26 | Correct | 49 ms | 12112 KB | Output is correct |
27 | Correct | 123 ms | 22024 KB | Output is correct |
28 | Correct | 113 ms | 22100 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 348 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 5 ms | 1116 KB | Output is correct |
37 | Correct | 132 ms | 22096 KB | Output is correct |
38 | Correct | 1 ms | 348 KB | Output is correct |
39 | Correct | 1 ms | 348 KB | Output is correct |
40 | Correct | 11 ms | 1116 KB | Output is correct |
41 | Correct | 134 ms | 22248 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 3 ms | 860 KB | Output is correct |
45 | Correct | 59 ms | 12056 KB | Output is correct |
46 | Correct | 1 ms | 344 KB | Output is correct |
47 | Correct | 1 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 62 ms | 5808 KB | Output is correct |
50 | Correct | 117 ms | 22044 KB | Output is correct |
51 | Correct | 123 ms | 22100 KB | Output is correct |
52 | Correct | 155 ms | 22080 KB | Output is correct |
53 | Correct | 57 ms | 12112 KB | Output is correct |
54 | Correct | 56 ms | 12040 KB | Output is correct |
55 | Correct | 130 ms | 22044 KB | Output is correct |
56 | Correct | 143 ms | 22040 KB | Output is correct |
57 | Correct | 53 ms | 12312 KB | Output is correct |
58 | Incorrect | 0 ms | 348 KB | Answer gives possible 1 while actual possible 0 |
59 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 1116 KB | Output is correct |
7 | Correct | 119 ms | 22100 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 1116 KB | Output is correct |
13 | Correct | 116 ms | 22100 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 55 ms | 12112 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 32 ms | 5712 KB | Output is correct |
21 | Correct | 116 ms | 22040 KB | Output is correct |
22 | Correct | 116 ms | 22100 KB | Output is correct |
23 | Correct | 127 ms | 22040 KB | Output is correct |
24 | Correct | 113 ms | 22044 KB | Output is correct |
25 | Correct | 50 ms | 12280 KB | Output is correct |
26 | Correct | 49 ms | 12112 KB | Output is correct |
27 | Correct | 123 ms | 22024 KB | Output is correct |
28 | Correct | 113 ms | 22100 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 348 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 5 ms | 1116 KB | Output is correct |
37 | Correct | 132 ms | 22096 KB | Output is correct |
38 | Correct | 1 ms | 348 KB | Output is correct |
39 | Correct | 1 ms | 348 KB | Output is correct |
40 | Correct | 11 ms | 1116 KB | Output is correct |
41 | Correct | 134 ms | 22248 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 3 ms | 860 KB | Output is correct |
45 | Correct | 59 ms | 12056 KB | Output is correct |
46 | Correct | 1 ms | 344 KB | Output is correct |
47 | Correct | 1 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 62 ms | 5808 KB | Output is correct |
50 | Correct | 117 ms | 22044 KB | Output is correct |
51 | Correct | 123 ms | 22100 KB | Output is correct |
52 | Correct | 155 ms | 22080 KB | Output is correct |
53 | Correct | 57 ms | 12112 KB | Output is correct |
54 | Correct | 56 ms | 12040 KB | Output is correct |
55 | Correct | 130 ms | 22044 KB | Output is correct |
56 | Correct | 143 ms | 22040 KB | Output is correct |
57 | Correct | 53 ms | 12312 KB | Output is correct |
58 | Correct | 0 ms | 348 KB | Output is correct |
59 | Correct | 1 ms | 348 KB | Output is correct |
60 | Correct | 1 ms | 348 KB | Output is correct |
61 | Correct | 40 ms | 5896 KB | Output is correct |
62 | Correct | 128 ms | 22024 KB | Output is correct |
63 | Correct | 122 ms | 22136 KB | Output is correct |
64 | Correct | 122 ms | 22044 KB | Output is correct |
65 | Correct | 0 ms | 344 KB | Output is correct |
66 | Correct | 28 ms | 5692 KB | Output is correct |
67 | Correct | 138 ms | 22096 KB | Output is correct |
68 | Correct | 144 ms | 22028 KB | Output is correct |
69 | Correct | 122 ms | 22096 KB | Output is correct |
70 | Correct | 0 ms | 348 KB | Output is correct |
71 | Correct | 0 ms | 348 KB | Output is correct |
72 | Incorrect | 0 ms | 348 KB | Too few ways to get from 0 to 1, should be 2 found 0 |
73 | Halted | 0 ms | 0 KB | - |