# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733693 | 2023-05-01T08:10:19 Z | tigar | Connecting Supertrees (IOI20_supertrees) | C++14 | 1 ms | 404 KB |
#include <bits/stdc++.h> #include "supertrees.h" using namespace std; typedef long long ll; vector<int> jedan[1010], dva[1010], nula[1010]; bitset<1010> jj[1010], sve[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; if(jj[x]!=jj[jedan[x][i]])return false; } for(int i=0; i<dva[x].size(); i++) { if(check[dva[x][i]])continue; check[dva[x][i]]=true; if(sve[x]!=sve[dva[x][i]])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){jj[i][j]=1; jj[j][i]=1; sve[j][i]=1; sve[i][j]=1;} else if(p[i][j]==2){sve[i][j]=1; sve[j][i]=1;} 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++) { //cout<<cc[i][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; } //cout<<endl; } for(int i=0; i<n; i++) { ans[i][i]=0; } //for(int i=0; i<n; i++){for(int j=0; j<n; j++)cout<<ans[i][j]<<" "; cout<<endl;} 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 | 0 ms | 340 KB | Output is correct |
2 | Incorrect | 0 ms | 340 KB | Too few ways to get from 0 to 1, should be 1 found 0 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Incorrect | 0 ms | 340 KB | Too few ways to get from 0 to 1, should be 1 found 0 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 404 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Incorrect | 1 ms | 340 KB | Answer gives possible 1 while actual possible 0 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Too few ways to get from 0 to 1, should be 2 found 0 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Incorrect | 0 ms | 340 KB | Too few ways to get from 0 to 1, should be 1 found 0 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Incorrect | 0 ms | 340 KB | Too few ways to get from 0 to 1, should be 1 found 0 |
3 | Halted | 0 ms | 0 KB | - |