# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
470338 | 2021-09-03T14:12:59 Z | jazzup | Connecting Supertrees (IOI20_supertrees) | C++17 | 1 ms | 332 KB |
#include"supertrees.h" #include<vector> using namespace std; int par[1010]; vector<int> heads; int findPar(int n){ if(par[n]==n)return n; return par[n]=findPar(par[n]); } bool c[1010]; int construct(vector<vector<int> > p) { int n = p.size(); for(int i=0;i<=n;i++){ par[i]=i; } 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;i++){ for(int j=0;j<n;j++){ answer[i].push_back(0); } } for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ if(p[i][j]==3)return 0; if(p[i][j]==1){ par[j]=findPar(i); answer[j][par[j]]=1; answer[par[j]][j]=1; } } } for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ if(p[i][j]==2){ if(findPar(i)==findPar(j)){ return 0; } c[findPar(i)]=true; c[findPar(j)]=true; } } } for(int i=0;i<n;i++){ if(c[i])heads.push_back(i); } for(int i=0;i<heads.size()-1;i++){ answer[heads[i]][heads[i+1]]=1; answer[heads[i+1]][heads[i]]=1; } answer[heads[heads.size()-1]][heads[0]]=1; answer[heads[0]][heads[heads.size()-1]]=1; build(answer); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |