# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108741 | 2024-11-04T21:53:05 Z | SteveBro | Connecting Supertrees (IOI20_supertrees) | C++17 | 1 ms | 336 KB |
#include <bits/stdc++.h> #include "supertrees.h" using namespace std; int n; vector <vector<int>> sol; int mat[1001][1001]; int sef[1001]; int ef(int x) { if(sef[x]==x) return x; else return sef[x]=ef(sef[x]); } vector <int> comp[1001],rez,l; bool ok[1001]; int construct(vector <vector <int>> p) { int i,j,nr; for(i=0;i<n;i++) sef[i]=i; for(i=0;i<n;i++) { for(j=0,nr=0;j<n;j++) { if(p[i][j]==3) return 0; if(p[i][j]==0&&ef(i)==ef(j)) return 0; if(p[i][j]>0) sef[ef(i)]=ef(j); if(p[i][j]==2) nr++; if(p[i][j]==1&&i!=j) ok[i]=true; } if(nr==1) return 0; } for(i=0;i<n;i++) comp[ef(i)].push_back(i); for(i=0;i<n;i++) sef[i]=-1; for(i=0;i<n;i++) { if(!comp[i].empty()) { rez.clear(); for(auto x : comp[i]) { if(!ok[x])/// se alfa pe ciclu rez.push_back(x); else { if(sef[x]==-1)///nou lant { rez.push_back(x); sef[x]=x; for(j=0;j<n;j++) { if(p[x][j]==1&&x!=j) { if(sef[j]==-1) { sef[j]=x; mat[x][j]=mat[j][x]=1; } else return 0; } } } else { for(j=0;j<n;j++) { if(p[x][j]==2&&sef[x]==sef[j]) return 0; if(p[x][j]==1&&sef[x]!=sef[j]) return 0; } } } } if(rez.size()>2) { for(j=1;j<rez.size();j++) { mat[rez[j-1]][rez[j]]=mat[rez[j]][rez[j-1]]=1; } mat[rez[0]][rez[j-1]]=mat[rez[j-1]][rez[0]]=1; } } } for(i=0;i<n;i++) { for(j=0;j<n;j++) l.push_back(mat[i][j]); sol.push_back(l); l.clear(); } build(sol); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | WA in grader: Invalid number of rows in b |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | WA in grader: Invalid number of rows in b |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | WA in grader: Invalid number of rows in b |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | WA in grader: Invalid number of rows in b |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | WA in grader: Invalid number of rows in b |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | WA in grader: Invalid number of rows in b |
2 | Halted | 0 ms | 0 KB | - |