# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733658 | 2023-05-01T07:19:03 Z | tigar | Connecting Supertrees (IOI20_supertrees) | C++14 | 177 ms | 26648 KB |
#include <bits/stdc++.h> #include "supertrees.h" using namespace std; typedef long long ll; vector<int> jedan[1010], dva[1010]; bool check[1010]; vector<int>lin; vector<int>cc[1010]; bool provera(int x, std::vector<std::vector<int>>p, int cmp) { lin.push_back(x); cc[cmp].push_back(x); int n=p.size(); for(int i=0; i<jedan[x].size(); i++) { if(check[jedan[x][i]])continue; check[jedan[x][i]]=true; for(int j=0; j<n; j++) { if(p[jedan[x][i]][j]!=p[x][j])return false; } } for(int i=0; i<dva[x].size(); i++) { if(check[dva[x][i]])continue; check[dva[x][i]]=true; for(int j=0; j<n; j++) { if(p[dva[x][i]][j]!=0 and p[x][j]==0)return false; if(p[dva[x][i]][j]==0 and p[x][j]!=0)return false; } if(!provera(dva[x][i], p, cmp))return false; } return true; } int construct(std::vector<std::vector<int>>p) { int n=p.size(); for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(p[i][j]==1)jedan[i].push_back(j); else if(p[i][j]==2)dva[i].push_back(j); else if(p[i][j]==3)return 0; } } int br=1; for(int i=0; i<n; i++) { if(check[i])continue; if(!provera(i, p, br))return 0; br++; } vector<vector<int> > ans(n); for(int i=0; i<n; i++){ans[i].resize(n, 0);} for(int i=0; i<lin.size(); i++) { for(int j=1; j<jedan[lin[i]].size(); j++) { ans[jedan[lin[i]][j]][jedan[lin[i]][j-1]]=1; ans[jedan[lin[i]][j-1]][jedan[lin[i]][j]]=1; } } for(int i=1; i<br; i++) { for(int j=0; j<cc[i].size(); j++) { if(cc[i].size()==2)return 0; ans[cc[i][j]][(cc[i][j]+1)%cc[i].size()]=1; ans[(cc[i][j]+1)%cc[i].size()][cc[i][j]]=1; } } for(int i=0; i<n; i++) { ans[i][i]=0; } build(ans); return 1; } /*int main() { int n; cin>>n; vector<vector<int> >p; for(int i=0; i<n; i++) { vector<int>pp(n); for(int j=0; j<n; j++) { cin>>pp[j]; } p.push_back(pp); } cout<<construct(p); }*/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 368 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 8 ms | 1480 KB | Output is correct |
7 | Correct | 177 ms | 26648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 368 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 8 ms | 1480 KB | Output is correct |
7 | Correct | 177 ms | 26648 KB | Output is correct |
8 | Incorrect | 1 ms | 372 KB | Too many ways to get from 0 to 1, should be 0 found no less than 1 |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Too many ways to get from 0 to 1, should be 0 found no less than 1 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Too many ways to get from 0 to 1, should be 0 found no less than 1 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 368 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 8 ms | 1480 KB | Output is correct |
7 | Correct | 177 ms | 26648 KB | Output is correct |
8 | Incorrect | 1 ms | 372 KB | Too many ways to get from 0 to 1, should be 0 found no less than 1 |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 368 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 8 ms | 1480 KB | Output is correct |
7 | Correct | 177 ms | 26648 KB | Output is correct |
8 | Incorrect | 1 ms | 372 KB | Too many ways to get from 0 to 1, should be 0 found no less than 1 |
9 | Halted | 0 ms | 0 KB | - |