# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
888219 | 2023-12-16T14:11:24 Z | 12345678 | Connecting Supertrees (IOI20_supertrees) | C++17 | 166 ms | 22328 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int nx=1e3+5; bool vs[nx]; vector<int> c[nx], l[nx]; int construct(std::vector<std::vector<int>> p) { int n = p.size(), cnt=0; for (int i=0; i<n; i++) for (int j=0; j<n; j++) if (p[i][j]==3) return 0; vector<vector<int>> answer(n, vector<int> (n, 0)); vector<int> h; for (int i=0; i<n; i++) { if (vs[i]) continue; vector<int> d; for (int j=0; j<n; j++) if (p[i][j]==1) vs[j]=1, d.push_back(j); for (auto u:d) for (auto v:d) if (p[u][v]!=1) return 0; h.push_back(i); c[i]=d; int sz=d.size(); for (int j=0; j<sz-1; j++) answer[d[j]][d[j+1]]=answer[d[j+1]][d[j]]=1; } for (int i=0; i<n; i++) vs[i]=0; for (int i=0; i<h.size(); i++) { if (vs[i]) continue; vector<int> d; for (auto j:h) if (p[i][j]) d.push_back(j), vs[j]=1; for (auto u:d) { for (auto x:c[u]) l[cnt].push_back(x); for (auto v:d) { if (v==u) continue; for (auto x:c[u]) for (auto y:c[v]) if (p[x][y]!=2) return 0; } } cnt++; if (d.size()==2) return 0; if (d.size()==1) continue; int sz=d.size(); for (int j=0; j<sz-1; j++) answer[d[j]][d[j+1]]=answer[d[j+1]][d[j]]=1; answer[d[0]][d[sz-1]]=answer[d[sz-1]][d[0]]=1; } for (int i=0; i<cnt; i++) { for (int j=i+1; j<cnt; j++) { for (auto x:l[i]) for (auto y:l[j]) if (p[x][y]!=0) return 0; } } build(answer); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 7 ms | 1228 KB | Output is correct |
7 | Correct | 153 ms | 22328 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 7 ms | 1228 KB | Output is correct |
7 | Correct | 153 ms | 22328 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1372 KB | Output is correct |
13 | Correct | 162 ms | 22068 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 856 KB | Output is correct |
17 | Correct | 67 ms | 12116 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Incorrect | 15 ms | 3416 KB | Answer gives possible 0 while actual possible 1 |
21 | 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 | 1 ms | 544 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 | 344 KB | Output is correct |
8 | Correct | 7 ms | 1372 KB | Output is correct |
9 | Correct | 156 ms | 22068 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1372 KB | Output is correct |
13 | Correct | 157 ms | 22236 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 860 KB | Output is correct |
17 | Correct | 72 ms | 12340 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 41 ms | 5824 KB | Output is correct |
22 | Correct | 156 ms | 22076 KB | Output is correct |
23 | Correct | 166 ms | 22232 KB | Output is correct |
24 | Correct | 158 ms | 22084 KB | Output is correct |
25 | Correct | 68 ms | 12372 KB | Output is correct |
26 | Correct | 66 ms | 12364 KB | Output is correct |
27 | Correct | 160 ms | 22068 KB | Output is correct |
28 | Correct | 161 ms | 22104 KB | Output is correct |
29 | Correct | 65 ms | 12368 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 | Incorrect | 16 ms | 3264 KB | Answer gives possible 0 while actual possible 1 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 7 ms | 1228 KB | Output is correct |
7 | Correct | 153 ms | 22328 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1372 KB | Output is correct |
13 | Correct | 162 ms | 22068 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 856 KB | Output is correct |
17 | Correct | 67 ms | 12116 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Incorrect | 15 ms | 3416 KB | Answer gives possible 0 while actual possible 1 |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 7 ms | 1228 KB | Output is correct |
7 | Correct | 153 ms | 22328 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1372 KB | Output is correct |
13 | Correct | 162 ms | 22068 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 856 KB | Output is correct |
17 | Correct | 67 ms | 12116 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Incorrect | 15 ms | 3416 KB | Answer gives possible 0 while actual possible 1 |
21 | Halted | 0 ms | 0 KB | - |