# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
953645 | 2024-03-26T11:43:22 Z | Desh03 | Connecting Supertrees (IOI20_supertrees) | C++17 | 178 ms | 23460 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(vector<vector<int>> p) { int n = p.size(); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (p[i][j] == 3) { return 0; } } } vector<bool> vis(n); vector<vector<int>> b(n, vector<int> (n)); for (int i = 0; i < n; i++) { if (vis[i]) continue; queue<int> q; q.push(i); vector<int> nodes; bool two = 0; while (q.size()) { int u = q.front(); q.pop(); if (vis[u]) continue; vis[u] = 1; nodes.push_back(u); for (int j = 0; j < n; j++) { if (!vis[j] && p[u][j]) { if (p[u][j] == 2) { two = 1; } q.push(j); } } } vector<vector<int>> trees; vector<bool> vis2(n); for (int u : nodes) { if (vis2[u]) continue; trees.push_back({}); queue<int> q2; q2.push(u); while (q2.size()) { int v = q2.front(); q2.pop(); if (vis2[v]) continue; vis2[v] = 1; trees.back().push_back(v); for (int j = 0; j < n; j++) { if (!vis2[j] && p[v][j] == 1) { q2.push(j); } } } } int sz = trees.size(); if (two && sz < 3) return 0; for (int j = 0; j < sz; j++) { for (int k = 0; k < trees[j].size(); k++) { for (int l = k + 1; l < trees[j].size(); l++) { if (p[trees[j][k]][trees[j][l]] > 1) { return 0; } } } } for (int j = 0; j < sz; j++) { int u = trees[j].back(), v = trees[(j + 1) % sz].back(); if (u != v) { b[u][v] = b[v][u] = 1; } for (int k = 0; k < trees[j].size() - 1; k++) { u = trees[j][k], v = trees[j][k + 1]; b[u][v] = b[v][u] = 1; } } } build(b); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 6 ms | 1188 KB | Output is correct |
7 | Correct | 148 ms | 23260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 6 ms | 1188 KB | Output is correct |
7 | Correct | 148 ms | 23260 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 155 ms | 23228 KB | Output is correct |
14 | Incorrect | 0 ms | 344 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 6 ms | 1260 KB | Output is correct |
9 | Correct | 152 ms | 23380 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 600 KB | Output is correct |
12 | Correct | 6 ms | 1364 KB | Output is correct |
13 | Correct | 149 ms | 23432 KB | Output is correct |
14 | Incorrect | 0 ms | 348 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 38 ms | 6212 KB | Output is correct |
5 | Correct | 162 ms | 23248 KB | Output is correct |
6 | Correct | 155 ms | 23268 KB | Output is correct |
7 | Correct | 158 ms | 23292 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 38 ms | 6376 KB | Output is correct |
10 | Correct | 148 ms | 23440 KB | Output is correct |
11 | Correct | 150 ms | 23460 KB | Output is correct |
12 | Correct | 178 ms | 23292 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 39 ms | 6488 KB | Output is correct |
17 | Correct | 152 ms | 23380 KB | Output is correct |
18 | Correct | 151 ms | 23380 KB | Output is correct |
19 | Correct | 150 ms | 23268 KB | Output is correct |
20 | Correct | 149 ms | 23256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 6 ms | 1188 KB | Output is correct |
7 | Correct | 148 ms | 23260 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 155 ms | 23228 KB | Output is correct |
14 | Incorrect | 0 ms | 344 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 6 ms | 1188 KB | Output is correct |
7 | Correct | 148 ms | 23260 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 155 ms | 23228 KB | Output is correct |
14 | Incorrect | 0 ms | 344 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |