# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
731298 | 2023-04-27T09:07:10 Z | TheSahib | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 201 ms | 24052 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int MAX = 1005; int par[MAX]; int find_set(int v){ if(par[v] < 0) return v; return par[v] = find_set(par[v]); } bool unite(int u, int v){ u = find_set(u); v = find_set(v); if(u == v) return false; par[u] += par[v]; par[v] = u; return true; } int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> ans(n, vector<int>(n)); memset(par, -1, sizeof(par)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if(p[i][j] == 1){ unite(i, j); } } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if(i == j) continue; if(p[i][j] == 0 && find_set(i) == find_set(j)){ return 0; } } } vector<int> comps[MAX]; for (int i = 0; i < n; i++) { comps[find_set(i)].push_back(i); } for(auto& v:comps){ for (int i = 0; i < v.size(); i++) { if(i != 0){ ans[v[i]][v[i - 1]] = 1; } if(i != v.size() - 1){ ans[v[i]][v[i + 1]] = 1; } } } build(ans); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1108 KB | Output is correct |
7 | Correct | 196 ms | 22168 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1108 KB | Output is correct |
7 | Correct | 196 ms | 22168 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1280 KB | Output is correct |
13 | Correct | 184 ms | 23956 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 824 KB | Output is correct |
17 | Correct | 97 ms | 14080 KB | Output is correct |
18 | Correct | 1 ms | 304 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 44 ms | 6220 KB | Output is correct |
21 | Correct | 175 ms | 23996 KB | Output is correct |
22 | Correct | 201 ms | 24036 KB | Output is correct |
23 | Correct | 191 ms | 23936 KB | Output is correct |
24 | Correct | 172 ms | 23940 KB | Output is correct |
25 | Correct | 78 ms | 14084 KB | Output is correct |
26 | Correct | 72 ms | 14068 KB | Output is correct |
27 | Correct | 192 ms | 23976 KB | Output is correct |
28 | Correct | 186 ms | 24052 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 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Too few ways to get from 0 to 1, should be 2 found 0 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1108 KB | Output is correct |
7 | Correct | 196 ms | 22168 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1280 KB | Output is correct |
13 | Correct | 184 ms | 23956 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 824 KB | Output is correct |
17 | Correct | 97 ms | 14080 KB | Output is correct |
18 | Correct | 1 ms | 304 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 44 ms | 6220 KB | Output is correct |
21 | Correct | 175 ms | 23996 KB | Output is correct |
22 | Correct | 201 ms | 24036 KB | Output is correct |
23 | Correct | 191 ms | 23936 KB | Output is correct |
24 | Correct | 172 ms | 23940 KB | Output is correct |
25 | Correct | 78 ms | 14084 KB | Output is correct |
26 | Correct | 72 ms | 14068 KB | Output is correct |
27 | Correct | 192 ms | 23976 KB | Output is correct |
28 | Correct | 186 ms | 24052 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 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1108 KB | Output is correct |
7 | Correct | 196 ms | 22168 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1280 KB | Output is correct |
13 | Correct | 184 ms | 23956 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 824 KB | Output is correct |
17 | Correct | 97 ms | 14080 KB | Output is correct |
18 | Correct | 1 ms | 304 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 44 ms | 6220 KB | Output is correct |
21 | Correct | 175 ms | 23996 KB | Output is correct |
22 | Correct | 201 ms | 24036 KB | Output is correct |
23 | Correct | 191 ms | 23936 KB | Output is correct |
24 | Correct | 172 ms | 23940 KB | Output is correct |
25 | Correct | 78 ms | 14084 KB | Output is correct |
26 | Correct | 72 ms | 14068 KB | Output is correct |
27 | Correct | 192 ms | 23976 KB | Output is correct |
28 | Correct | 186 ms | 24052 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 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |