# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
808053 | 2023-08-05T04:29:23 Z | The_Samurai | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 514 ms | 22348 KB |
#include "bits/stdc++.h" #ifdef sunnatov #include "grader.cpp" #else #include "supertrees.h" #endif using namespace std; struct dsu { vector<int> p, size; void init(int n) { p.assign(n, 0); size.assign(n, 1); for (int i = 0; i < n; i++) p[i] = i; } int get(int a) { return p[a] == a ? a : p[a] = get(p[a]); } void add(int a, int b) { a = get(a); b = get(b); if (a == b) return; if (size[a] > size[b]) swap(a, b); size[b] += size[a]; p[a] = b; } }; int construct(std::vector<std::vector<int>> p) { int n = p.size(); vector<vector<int>> g(n, vector<int>(n)); dsu ds; ds.init(n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (p[i][j] == 1) { ds.add(i, j); } } } vector<bool> vis(n); for (int _ = 0; _ < n; _++) { int s = -1; vector<int> v; for (int i = 0; i < n; i++) { if (vis[i]) continue; if (s == -1) s = ds.get(i); if (ds.get(i) != s) continue; v.emplace_back(i); } if (v.empty()) break; for (int i = 0; i < v.size(); i++) { for (int j = i + 1; j < v.size(); j++) { if (!p[v[i]][v[j]]) return 0; } } for (int i = 1; i < v.size(); i++) g[v[i - 1]][v[i]] = g[v[i]][v[i - 1]] = 1; } build(g); 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 | 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 | 12 ms | 1184 KB | Output is correct |
7 | Correct | 514 ms | 22000 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 | 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 | 12 ms | 1184 KB | Output is correct |
7 | Correct | 514 ms | 22000 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 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 | 7 ms | 1236 KB | Output is correct |
13 | Correct | 159 ms | 22348 KB | Output is correct |
14 | Incorrect | 1 ms | 300 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Incorrect | 1 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 | 1 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 | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 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 | 12 ms | 1184 KB | Output is correct |
7 | Correct | 514 ms | 22000 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 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 | 7 ms | 1236 KB | Output is correct |
13 | Correct | 159 ms | 22348 KB | Output is correct |
14 | Incorrect | 1 ms | 300 KB | Answer gives possible 1 while actual possible 0 |
15 | 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 | 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 | 12 ms | 1184 KB | Output is correct |
7 | Correct | 514 ms | 22000 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 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 | 7 ms | 1236 KB | Output is correct |
13 | Correct | 159 ms | 22348 KB | Output is correct |
14 | Incorrect | 1 ms | 300 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |