# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977271 | 2024-05-07T15:28:15 Z | AliHasanli | Connecting Supertrees (IOI20_supertrees) | C++17 | 164 ms | 22404 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;break;} 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 | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 7 ms | 1116 KB | Output is correct |
7 | Correct | 152 ms | 22024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 7 ms | 1116 KB | Output is correct |
7 | Correct | 152 ms | 22024 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1116 KB | Output is correct |
13 | Correct | 164 ms | 22404 KB | Output is correct |
14 | Incorrect | 1 ms | 348 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 | 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 | 348 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 | 0 ms | 348 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 | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 7 ms | 1116 KB | Output is correct |
7 | Correct | 152 ms | 22024 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1116 KB | Output is correct |
13 | Correct | 164 ms | 22404 KB | Output is correct |
14 | Incorrect | 1 ms | 348 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 | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 7 ms | 1116 KB | Output is correct |
7 | Correct | 152 ms | 22024 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1116 KB | Output is correct |
13 | Correct | 164 ms | 22404 KB | Output is correct |
14 | Incorrect | 1 ms | 348 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |