# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
822999 | 2023-08-12T06:49:42 Z | fatemetmhr | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 180 ms | 26132 KB |
// :) #include "supertrees.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define fi first #define se second #define mp make_pair #define pb push_back typedef long long ll; const int maxn5 = 1e3 + 10; vector<vector<int>> ret; vector <int> tp, av, ver; bool mark[maxn5], mark2[maxn5]; int n, a[maxn5][maxn5]; void dfs0(int v){ mark[v] = true; ver.pb(v); for(int i = 0; i < n; i++) if(a[v][i] > 0 && !mark[i]) dfs0(i); } void dfs1(int v){ mark2[v] = true; av.pb(v); for(int i = 0; i < n; i++) if(a[v][i] == 1 && !mark2[i]){ ret[v][i] = ret[i][v] = 1; dfs1(i); return; } } int construct(std::vector<std::vector<int>> p) { n = p.size(); for (int i = 0; i < n; i++){ vector<int> row; row.resize(n); fill(all(row), 0); ret.push_back(row); for(int j = 0; j < n; j++) a[i][j] = p[i][j]; } for(int i = 0; i < n; i++) if(!mark[i]){ ver.clear(); tp.clear(); dfs0(i); for(int j = 0; j < ver.size(); j++) for(int k = 0; k < ver.size(); k++) if(a[ver[j]][ver[k]] == 0) return 0; for(auto u : ver) if(!mark2[u]){ av.clear(); dfs1(u); for(int i = 0; i < av.size(); i++) for(int j = 0; j < av.size(); j++) if(a[av[i]][av[j]] != 1) return 0; tp.pb(u); } for(int i = 1; i < int(tp.size()); i++) ret[tp[i]][tp[i - 1]] = ret[tp[i - 1]][tp[i]] = 1; if(tp.size() > 1) ret[tp.back()][tp[0]] = ret[tp[0]][tp.back()] = 1; } build(ret); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 7 ms | 2004 KB | Output is correct |
7 | Correct | 168 ms | 25992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 7 ms | 2004 KB | Output is correct |
7 | Correct | 168 ms | 25992 KB | Output is correct |
8 | Correct | 0 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 | 340 KB | Output is correct |
12 | Correct | 7 ms | 1876 KB | Output is correct |
13 | Correct | 157 ms | 26008 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 1492 KB | Output is correct |
17 | Correct | 84 ms | 16108 KB | Output is correct |
18 | Correct | 0 ms | 224 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 50 ms | 7708 KB | Output is correct |
21 | Correct | 162 ms | 26008 KB | Output is correct |
22 | Correct | 162 ms | 26008 KB | Output is correct |
23 | Correct | 173 ms | 26000 KB | Output is correct |
24 | Correct | 156 ms | 25996 KB | Output is correct |
25 | Correct | 67 ms | 16076 KB | Output is correct |
26 | Correct | 66 ms | 16024 KB | Output is correct |
27 | Correct | 163 ms | 25996 KB | Output is correct |
28 | Correct | 171 ms | 25996 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 | 1 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 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 42 ms | 7692 KB | Output is correct |
5 | Correct | 159 ms | 25932 KB | Output is correct |
6 | Correct | 159 ms | 25992 KB | Output is correct |
7 | Correct | 165 ms | 25996 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 40 ms | 7664 KB | Output is correct |
10 | Correct | 159 ms | 25952 KB | Output is correct |
11 | Correct | 180 ms | 26132 KB | Output is correct |
12 | Correct | 162 ms | 26004 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 40 ms | 7752 KB | Output is correct |
17 | Correct | 162 ms | 26000 KB | Output is correct |
18 | Correct | 169 ms | 25948 KB | Output is correct |
19 | Correct | 165 ms | 25960 KB | Output is correct |
20 | Correct | 158 ms | 25908 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 7 ms | 2004 KB | Output is correct |
7 | Correct | 168 ms | 25992 KB | Output is correct |
8 | Correct | 0 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 | 340 KB | Output is correct |
12 | Correct | 7 ms | 1876 KB | Output is correct |
13 | Correct | 157 ms | 26008 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 1492 KB | Output is correct |
17 | Correct | 84 ms | 16108 KB | Output is correct |
18 | Correct | 0 ms | 224 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 50 ms | 7708 KB | Output is correct |
21 | Correct | 162 ms | 26008 KB | Output is correct |
22 | Correct | 162 ms | 26008 KB | Output is correct |
23 | Correct | 173 ms | 26000 KB | Output is correct |
24 | Correct | 156 ms | 25996 KB | Output is correct |
25 | Correct | 67 ms | 16076 KB | Output is correct |
26 | Correct | 66 ms | 16024 KB | Output is correct |
27 | Correct | 163 ms | 25996 KB | Output is correct |
28 | Correct | 171 ms | 25996 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 7 ms | 2004 KB | Output is correct |
7 | Correct | 168 ms | 25992 KB | Output is correct |
8 | Correct | 0 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 | 340 KB | Output is correct |
12 | Correct | 7 ms | 1876 KB | Output is correct |
13 | Correct | 157 ms | 26008 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 1492 KB | Output is correct |
17 | Correct | 84 ms | 16108 KB | Output is correct |
18 | Correct | 0 ms | 224 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 50 ms | 7708 KB | Output is correct |
21 | Correct | 162 ms | 26008 KB | Output is correct |
22 | Correct | 162 ms | 26008 KB | Output is correct |
23 | Correct | 173 ms | 26000 KB | Output is correct |
24 | Correct | 156 ms | 25996 KB | Output is correct |
25 | Correct | 67 ms | 16076 KB | Output is correct |
26 | Correct | 66 ms | 16024 KB | Output is correct |
27 | Correct | 163 ms | 25996 KB | Output is correct |
28 | Correct | 171 ms | 25996 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 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 | - |