# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977239 | 2024-05-07T14:40:11 Z | AliHasanli | Connecting Supertrees (IOI20_supertrees) | C++17 | 158 ms | 24148 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int par[1001],siz[1001]; int findd(int a) { if(a==par[a])return a; return par[a]=findd(par[a]); } bool unionn(int a,int b) { a=findd(a),b=findd(b); if(a!=b) { if(siz[b]>siz[a]) swap(a,b); par[b]=a; siz[a]+=siz[b]; return 1; } return 0; } bool check(int a,int b) { a=findd(a),b=findd(b); if(a!=b)return 1; return 0; } int construct(vector<vector<int>> p) { for(int i=0;i<1001;i++) { par[i]=i; siz[i]=1; } int n = p.size(); for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) if(p[i][j]==3)return 0; vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row; row.resize(n); answer.push_back(row); } //for(int i=0;i<n-1;i++) // for(int j=i+1;j<n;j++) // if(p[i][j]==0 && !check(i,j))return 0; for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) if(p[i][j] && unionn(i,j))answer[i][j]=1,answer[j][i]=1; for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) if(p[i][j]==0 && !check(i,j))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 | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 1108 KB | Output is correct |
7 | Correct | 155 ms | 22028 KB | Output is correct |
# | 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 | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 1108 KB | Output is correct |
7 | Correct | 155 ms | 22028 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 440 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 154 ms | 23988 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 756 KB | Output is correct |
16 | Correct | 4 ms | 860 KB | Output is correct |
17 | Correct | 71 ms | 14164 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 39 ms | 6228 KB | Output is correct |
21 | Correct | 156 ms | 24076 KB | Output is correct |
22 | Correct | 153 ms | 24148 KB | Output is correct |
23 | Correct | 158 ms | 24148 KB | Output is correct |
24 | Correct | 157 ms | 23952 KB | Output is correct |
25 | Correct | 63 ms | 14076 KB | Output is correct |
26 | Correct | 64 ms | 14204 KB | Output is correct |
27 | Correct | 158 ms | 24004 KB | Output is correct |
28 | Correct | 155 ms | 24072 KB | Output is correct |
# | 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 | Incorrect | 0 ms | 600 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 | 348 KB | Output is correct |
2 | Incorrect | 1 ms | 436 KB | Too few ways to get from 0 to 1, should be 2 found 1 |
3 | 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 | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 1108 KB | Output is correct |
7 | Correct | 155 ms | 22028 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 440 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 154 ms | 23988 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 756 KB | Output is correct |
16 | Correct | 4 ms | 860 KB | Output is correct |
17 | Correct | 71 ms | 14164 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 39 ms | 6228 KB | Output is correct |
21 | Correct | 156 ms | 24076 KB | Output is correct |
22 | Correct | 153 ms | 24148 KB | Output is correct |
23 | Correct | 158 ms | 24148 KB | Output is correct |
24 | Correct | 157 ms | 23952 KB | Output is correct |
25 | Correct | 63 ms | 14076 KB | Output is correct |
26 | Correct | 64 ms | 14204 KB | Output is correct |
27 | Correct | 158 ms | 24004 KB | Output is correct |
28 | Correct | 155 ms | 24072 KB | Output is correct |
29 | Correct | 0 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 | Incorrect | 0 ms | 600 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 | 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 | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 1108 KB | Output is correct |
7 | Correct | 155 ms | 22028 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 440 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 154 ms | 23988 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 756 KB | Output is correct |
16 | Correct | 4 ms | 860 KB | Output is correct |
17 | Correct | 71 ms | 14164 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 39 ms | 6228 KB | Output is correct |
21 | Correct | 156 ms | 24076 KB | Output is correct |
22 | Correct | 153 ms | 24148 KB | Output is correct |
23 | Correct | 158 ms | 24148 KB | Output is correct |
24 | Correct | 157 ms | 23952 KB | Output is correct |
25 | Correct | 63 ms | 14076 KB | Output is correct |
26 | Correct | 64 ms | 14204 KB | Output is correct |
27 | Correct | 158 ms | 24004 KB | Output is correct |
28 | Correct | 155 ms | 24072 KB | Output is correct |
29 | Correct | 0 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 | Incorrect | 0 ms | 600 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |