# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
822997 | 2023-08-12T06:48:01 Z | fatemetmhr | Connecting Supertrees (IOI20_supertrees) | C++17 | 177 ms | 26040 KB |
// :) #include "supertrees.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define fi first #define se second #define mp make_pair #define pb push_back typedef long long ll; const int maxn5 = 1e3 + 10; vector<vector<int>> ret; vector <int> tp, av, ver; bool mark[maxn5], mark2[maxn5]; int n, a[maxn5][maxn5]; void dfs0(int v){ mark[v] = true; ver.pb(v); for(int i = 0; i < n; i++) if(a[v][i] > 0 && !mark[i]) dfs0(i); } void dfs1(int v){ mark2[v] = true; av.pb(v); for(int i = 0; i < n; i++) if(a[v][i] == 1 && !mark2[i]){ ret[v][i] = ret[i][v] = 1; dfs1(i); return; } } int construct(std::vector<std::vector<int>> p) { n = p.size(); for (int i = 0; i < n; i++){ vector<int> row; row.resize(n); fill(all(row), 0); ret.push_back(row); for(int j = 0; j < n; j++) a[i][j] = p[i][j]; } for(int i = 0; i < n; i++) if(!mark[i]){ ver.clear(); for(int j = 0; j < ver.size(); j++) for(int k = 0; k < ver.size(); k++) if(a[ver[j]][ver[k]] == 0) return 0; tp.clear(); dfs0(i); for(auto u : ver) if(!mark2[u]){ av.clear(); dfs1(u); for(int i = 0; i < av.size(); i++) for(int j = 0; j < av.size(); j++) if(a[av[i]][av[j]] != 1) return 0; tp.pb(u); } for(int i = 1; i < int(tp.size()); i++) ret[tp[i]][tp[i - 1]] = ret[tp[i - 1]][tp[i]] = 1; if(tp.size() > 1) ret[tp.back()][tp[0]] = ret[tp[0]][tp.back()] = 1; } build(ret); 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 | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 11 ms | 2004 KB | Output is correct |
7 | Correct | 163 ms | 26028 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 | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 11 ms | 2004 KB | Output is correct |
7 | Correct | 163 ms | 26028 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 | 340 KB | Output is correct |
12 | Correct | 7 ms | 1876 KB | Output is correct |
13 | Correct | 158 ms | 26008 KB | Output is correct |
14 | Incorrect | 0 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 | 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 | 1 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 | 41 ms | 7680 KB | Output is correct |
5 | Correct | 164 ms | 25908 KB | Output is correct |
6 | Correct | 160 ms | 25988 KB | Output is correct |
7 | Correct | 164 ms | 26040 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 41 ms | 7648 KB | Output is correct |
10 | Correct | 177 ms | 26020 KB | Output is correct |
11 | Correct | 159 ms | 25972 KB | Output is correct |
12 | Correct | 162 ms | 25932 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 46 ms | 7692 KB | Output is correct |
17 | Correct | 163 ms | 25924 KB | Output is correct |
18 | Correct | 158 ms | 26008 KB | Output is correct |
19 | Correct | 158 ms | 26000 KB | Output is correct |
20 | Correct | 159 ms | 26000 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 | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 11 ms | 2004 KB | Output is correct |
7 | Correct | 163 ms | 26028 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 | 340 KB | Output is correct |
12 | Correct | 7 ms | 1876 KB | Output is correct |
13 | Correct | 158 ms | 26008 KB | Output is correct |
14 | Incorrect | 0 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 | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 11 ms | 2004 KB | Output is correct |
7 | Correct | 163 ms | 26028 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 | 340 KB | Output is correct |
12 | Correct | 7 ms | 1876 KB | Output is correct |
13 | Correct | 158 ms | 26008 KB | Output is correct |
14 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |