# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014667 | 2024-07-05T09:10:46 Z | Unforgettablepl | Connecting Supertrees (IOI20_supertrees) | C++17 | 136 ms | 24216 KB |
#include <bits/stdc++.h> using namespace std; void build(std::vector<std::vector<int>> b); int construct(std::vector<std::vector<int>> p) { int n = p.size(); vector<vector<vector<int>>> components; vector<int> componentstype; for(int i=0;i<n;i++){ int mycomponent = -1; for(int compo=0;compo<components.size();compo++){ int shouldbe = p[i][components[compo][0][0]]; shouldbe = min(shouldbe,1); if(shouldbe==1){ if(mycomponent==-1)mycomponent=compo; else return 0; } for(auto&j:components[compo]){ for(int&k:j){ if(shouldbe==0 and p[i][k]!=0)return 0; if(shouldbe==1 and p[i][k]==0)return 0; } } } if(mycomponent==-1){ components.push_back({{i}}); componentstype.push_back(-1); continue; } int mychain = -1; for(int cha=0;cha<components[mycomponent].size();cha++){ int shouldbe = p[i][components[mycomponent][cha][0]]; if(shouldbe==1){ if(mychain==-1)mychain=cha; else return 0; } else { if(componentstype[mycomponent]==-1)componentstype[mycomponent]=shouldbe; else if(componentstype[mycomponent]!=shouldbe)return 0; } for(int&j:components[mycomponent][cha]){ if(shouldbe!=p[i][j])return 0; } } if(mychain==-1)components[mycomponent].push_back({i}); else components[mycomponent][mychain].push_back(i); } vector<vector<int>> ans(n,vector<int>(n)); for(int i=0;i<components.size();i++){ vector<int> heads; for(auto&j:components[i]){ heads.emplace_back(j[0]); for(int k=1;k<j.size();k++){ ans[j[k-1]][j[k]]=ans[j[k]][j[k-1]]=true; } } if(heads.size()==2)return 0; if(heads.size()==1)continue; if(componentstype[i]==3 and heads.size()==3)return 0; heads.emplace_back(heads.front()); for(int j=1;j<heads.size();j++){ ans[heads[j-1]][heads[j]]=ans[heads[j]][heads[j-1]]=true; } ans[heads[0]][heads[2]]=ans[heads[2]][heads[0]]=true; } build(ans); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 1372 KB | Output is correct |
7 | Correct | 113 ms | 23944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 1372 KB | Output is correct |
7 | Correct | 113 ms | 23944 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 1192 KB | Output is correct |
13 | Correct | 129 ms | 24216 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 3 ms | 700 KB | Output is correct |
17 | Correct | 57 ms | 10120 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 29 ms | 6228 KB | Output is correct |
21 | Correct | 128 ms | 23928 KB | Output is correct |
22 | Correct | 116 ms | 23996 KB | Output is correct |
23 | Correct | 134 ms | 24064 KB | Output is correct |
24 | Correct | 115 ms | 24036 KB | Output is correct |
25 | Correct | 48 ms | 10064 KB | Output is correct |
26 | Correct | 49 ms | 10120 KB | Output is correct |
27 | Correct | 121 ms | 23940 KB | Output is correct |
28 | Correct | 114 ms | 24144 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 | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 1216 KB | Output is correct |
9 | Correct | 114 ms | 24148 KB | Output is correct |
10 | Incorrect | 0 ms | 348 KB | Too many ways to get from 0 to 4, should be 2 found no less than 3 |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | 39 ms | 6204 KB | Output is correct |
5 | Correct | 136 ms | 24144 KB | Output is correct |
6 | Correct | 111 ms | 24144 KB | Output is correct |
7 | Correct | 122 ms | 24144 KB | Output is correct |
8 | Incorrect | 1 ms | 348 KB | Too many ways to get from 0 to 3, should be 2 found no less than 3 |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 1372 KB | Output is correct |
7 | Correct | 113 ms | 23944 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 1192 KB | Output is correct |
13 | Correct | 129 ms | 24216 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 3 ms | 700 KB | Output is correct |
17 | Correct | 57 ms | 10120 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 29 ms | 6228 KB | Output is correct |
21 | Correct | 128 ms | 23928 KB | Output is correct |
22 | Correct | 116 ms | 23996 KB | Output is correct |
23 | Correct | 134 ms | 24064 KB | Output is correct |
24 | Correct | 115 ms | 24036 KB | Output is correct |
25 | Correct | 48 ms | 10064 KB | Output is correct |
26 | Correct | 49 ms | 10120 KB | Output is correct |
27 | Correct | 121 ms | 23940 KB | Output is correct |
28 | Correct | 114 ms | 24144 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 6 ms | 1216 KB | Output is correct |
37 | Correct | 114 ms | 24148 KB | Output is correct |
38 | Incorrect | 0 ms | 348 KB | Too many ways to get from 0 to 4, should be 2 found no less than 3 |
39 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 5 ms | 1372 KB | Output is correct |
7 | Correct | 113 ms | 23944 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 1192 KB | Output is correct |
13 | Correct | 129 ms | 24216 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 3 ms | 700 KB | Output is correct |
17 | Correct | 57 ms | 10120 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 29 ms | 6228 KB | Output is correct |
21 | Correct | 128 ms | 23928 KB | Output is correct |
22 | Correct | 116 ms | 23996 KB | Output is correct |
23 | Correct | 134 ms | 24064 KB | Output is correct |
24 | Correct | 115 ms | 24036 KB | Output is correct |
25 | Correct | 48 ms | 10064 KB | Output is correct |
26 | Correct | 49 ms | 10120 KB | Output is correct |
27 | Correct | 121 ms | 23940 KB | Output is correct |
28 | Correct | 114 ms | 24144 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 6 ms | 1216 KB | Output is correct |
37 | Correct | 114 ms | 24148 KB | Output is correct |
38 | Incorrect | 0 ms | 348 KB | Too many ways to get from 0 to 4, should be 2 found no less than 3 |
39 | Halted | 0 ms | 0 KB | - |