# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
790201 | 2023-07-22T12:03:32 Z | Andrey | Connecting Supertrees (IOI20_supertrees) | C++14 | 159 ms | 28000 KB |
#include "supertrees.h" #include <vector> #include<bits/stdc++.h> using namespace std; vector<vector<int>> ans(0); vector<vector<int>> haha(0); vector<bool> bruh(3001,true); int n; vector<int> col(3000,-1); vector<int> no(3000,-1); void dfs(int a, int c) { col[a] = c; if(a != c) { ans[a][c] = 1; ans[c][a] = 1; } for(int i = 0; i < n; i++) { if(col[i] == -1 && haha[a][i] == 1) { dfs(i,c); } } } int construct(vector<vector<int>> p) { n = p[0].size(); haha = p; vector<int> wut(0); for(int i = 0; i < n; i++) { ans.push_back(vector<int> (n)); } for(int i = 0; i < n; i++) { if(col[i] == -1) { dfs(i,i); wut.push_back(i); } } for(int i = 0; i < wut.size(); i++) { if(no[wut[i]] == -1) { vector<int> wow(0); wow.push_back(wut[i]); no[wut[i]] = i; for(int j = 0; j < wut.size(); j++) { if(haha[wut[i]][wut[j]] == 2 && no[wut[j]] == -1) { bruh[j] = false; wow.push_back(wut[j]); no[wut[j]] = i; } } /* if(wow.size() == 2) { return 0; }*/ if(wow.size() > 1) { for(int j = 0; j < wow.size(); j++) { ans[wow[j]][wow[(j+1)%(int)wow.size()]] = 1; ans[wow[(j+1)%(int)wow.size()]][wow[j]] = 1; } } } } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(i != j) { if((col[i] == col[j]) && haha[i][j] != 1) { return 0; } if((col[i] != col[j] && no[col[i]] == no[col[j]]) && haha[i][j] != 2) { return 0; } if(no[col[i]] != no[col[j]] && haha[i][j] != 0) { return 0; } } } } build(ans); return 1; }
Compilation message
# | Verdict | Execution time | Memory | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1324 KB | Output is correct |
7 | Correct | 147 ms | 25996 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1324 KB | Output is correct |
7 | Correct | 147 ms | 25996 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 | 212 KB | Output is correct |
12 | Correct | 6 ms | 1364 KB | Output is correct |
13 | Correct | 149 ms | 26020 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 65 ms | 16024 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 38 ms | 6684 KB | Output is correct |
21 | Correct | 155 ms | 27980 KB | Output is correct |
22 | Correct | 148 ms | 27924 KB | Output is correct |
23 | Correct | 159 ms | 28000 KB | Output is correct |
24 | Correct | 153 ms | 27908 KB | Output is correct |
25 | Correct | 62 ms | 17984 KB | Output is correct |
26 | Correct | 62 ms | 18028 KB | Output is correct |
27 | Correct | 153 ms | 27988 KB | Output is correct |
28 | Correct | 151 ms | 27980 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 | 37 ms | 6720 KB | Output is correct |
5 | Correct | 153 ms | 26200 KB | Output is correct |
6 | Correct | 152 ms | 26228 KB | Output is correct |
7 | Correct | 156 ms | 26288 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 38 ms | 6904 KB | Output is correct |
10 | Correct | 152 ms | 26176 KB | Output is correct |
11 | Correct | 149 ms | 26188 KB | Output is correct |
12 | Correct | 158 ms | 26288 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 324 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 38 ms | 6904 KB | Output is correct |
17 | Correct | 154 ms | 26248 KB | Output is correct |
18 | Correct | 154 ms | 26192 KB | Output is correct |
19 | Correct | 153 ms | 26292 KB | Output is correct |
20 | Correct | 152 ms | 26384 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1324 KB | Output is correct |
7 | Correct | 147 ms | 25996 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 | 212 KB | Output is correct |
12 | Correct | 6 ms | 1364 KB | Output is correct |
13 | Correct | 149 ms | 26020 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 65 ms | 16024 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 38 ms | 6684 KB | Output is correct |
21 | Correct | 155 ms | 27980 KB | Output is correct |
22 | Correct | 148 ms | 27924 KB | Output is correct |
23 | Correct | 159 ms | 28000 KB | Output is correct |
24 | Correct | 153 ms | 27908 KB | Output is correct |
25 | Correct | 62 ms | 17984 KB | Output is correct |
26 | Correct | 62 ms | 18028 KB | Output is correct |
27 | Correct | 153 ms | 27988 KB | Output is correct |
28 | Correct | 151 ms | 27980 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 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 | - |
# | Verdict | Execution time | Memory | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1324 KB | Output is correct |
7 | Correct | 147 ms | 25996 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 | 212 KB | Output is correct |
12 | Correct | 6 ms | 1364 KB | Output is correct |
13 | Correct | 149 ms | 26020 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 65 ms | 16024 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 38 ms | 6684 KB | Output is correct |
21 | Correct | 155 ms | 27980 KB | Output is correct |
22 | Correct | 148 ms | 27924 KB | Output is correct |
23 | Correct | 159 ms | 28000 KB | Output is correct |
24 | Correct | 153 ms | 27908 KB | Output is correct |
25 | Correct | 62 ms | 17984 KB | Output is correct |
26 | Correct | 62 ms | 18028 KB | Output is correct |
27 | Correct | 153 ms | 27988 KB | Output is correct |
28 | Correct | 151 ms | 27980 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 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 | - |