# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
826990 | 2023-08-16T07:51:21 Z | tomruk | Connecting Supertrees (IOI20_supertrees) | C++17 | 176 ms | 22836 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> answer(n,(vector<int>(n,0))); vector<bool> used(n,0); function<void(int)> dfs = [&](int v)->void{ used[v] = 1; for(int i = 0;i<n;i++){ // cout << v << ' ' << i << endl; // cout << p[v][i] << endl; if(!used[i] && p[v][i]){ dfs(i); answer[v][i] = 1; answer[i][v] = 1; } } }; for(int i = 0;i<n;i++){ if(used[i])continue; int now = i; vector<int> tmp; int num = -1; set<int> s; for(int j = 0;j<n;j++){ if(p[now][j] >= 2){ s.insert(j); } } // cout << "HEy" << endl; while(s.size()){ // cout << now << ' ' << i << endl; tmp.push_back(now); used[now] = 1; vector<int> del; for(auto u:s){ if(p[now][u] < 2){ del.push_back(u); } } for(auto u:del) s.erase(u); if(s.empty()) break; now = *s.begin(); } // cout << tmp.size() << endl; if(tmp.empty()) continue; if(tmp.size() < 3){ return 0; } for(int i = 0;i<tmp.size();i++){ answer[tmp[i]][tmp[(i + 1)%tmp.size()]] = 1; answer[tmp[(i + 1)%tmp.size()]][tmp[i]] = 1; } if(p[tmp[0]][tmp[1]] == 3){ if(tmp.size() < 4) return 0; answer[tmp[i]][tmp[(i + 2)%tmp.size()]] = 1; answer[tmp[(i + 2)%tmp.size()]][tmp[i]] = 1; } for(auto u:tmp){ dfs(u); } } for(int i = 0;i<n;i++){ // cout << used[i] << endl; if(!used[i]) dfs(i); } build(answer); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1236 KB | Output is correct |
7 | Correct | 176 ms | 22696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1236 KB | Output is correct |
7 | Correct | 176 ms | 22696 KB | Output is correct |
8 | Correct | 1 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 | 0 ms | 212 KB | Output is correct |
12 | Correct | 10 ms | 1236 KB | Output is correct |
13 | Correct | 153 ms | 22668 KB | Output is correct |
14 | Incorrect | 1 ms | 212 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 | 212 KB | Output is correct |
2 | Correct | 0 ms | 296 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 9 ms | 1208 KB | Output is correct |
9 | Correct | 155 ms | 22836 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 7 ms | 1236 KB | Output is correct |
13 | Correct | 161 ms | 22452 KB | Output is correct |
14 | Incorrect | 1 ms | 212 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 | 304 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 0 ms | 296 KB | Output is correct |
4 | Correct | 39 ms | 6200 KB | Output is correct |
5 | Correct | 173 ms | 22624 KB | Output is correct |
6 | Correct | 164 ms | 22672 KB | Output is correct |
7 | Correct | 164 ms | 22712 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 39 ms | 5964 KB | Output is correct |
10 | Correct | 163 ms | 22380 KB | Output is correct |
11 | Correct | 157 ms | 22476 KB | Output is correct |
12 | Correct | 159 ms | 22332 KB | Output is correct |
13 | Correct | 1 ms | 296 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Incorrect | 41 ms | 6036 KB | Too many ways to get from 23 to 253, should be 1 found no less than 2 |
17 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1236 KB | Output is correct |
7 | Correct | 176 ms | 22696 KB | Output is correct |
8 | Correct | 1 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 | 0 ms | 212 KB | Output is correct |
12 | Correct | 10 ms | 1236 KB | Output is correct |
13 | Correct | 153 ms | 22668 KB | Output is correct |
14 | Incorrect | 1 ms | 212 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 | 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 | 1236 KB | Output is correct |
7 | Correct | 176 ms | 22696 KB | Output is correct |
8 | Correct | 1 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 | 0 ms | 212 KB | Output is correct |
12 | Correct | 10 ms | 1236 KB | Output is correct |
13 | Correct | 153 ms | 22668 KB | Output is correct |
14 | Incorrect | 1 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |