# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733764 | 2023-05-01T09:22:57 Z | tigar | Connecting Supertrees (IOI20_supertrees) | C++14 | 231 ms | 24160 KB |
#include <bits/stdc++.h> #include "supertrees.h" using namespace std; typedef long long ll; vector<int> jedan[1010], dva[1010], nula[1010]; bool check[1010]; vector<int>lin; vector<int>cc[1010]; int linije[1010], komponente[1010]; int construct(std::vector<std::vector<int>>p) { int n=p.size(); int br=1; for(int i=0; i<n; i++)linije[i]=-1; for(int i=0; i<n; i++) { if(!check[i]) { check[i]=true; lin.push_back(i); linije[i]=i; bool z=false; for(int j=0; j<n; j++) { if(!z and p[i][j]!=0) { z=true; if(komponente[j]!=0){komponente[i]=komponente[j]; cc[komponente[i]].push_back(i);} else {komponente[i]=br; cc[br].push_back(i); br++;} } if(p[i][j]==1) { if(linije[j]!=-1 and linije[i]!=linije[j])return 0; linije[j]=i; check[j]=true; if(komponente[j]!=0 and komponente[j]!=komponente[i])return 0; komponente[j]=komponente[i]; jedan[i].push_back(j); } else if(p[i][j]==2) { if(komponente[j]!=0 and komponente[j]!=komponente[i])return 0; komponente[j]=komponente[i]; } else if(p[i][j]==3)return 0; } } else { for(int j=0; j<n; j++) { if(p[i][j]!=p[linije[i]][j])return 0; } } } ///ovde pocinje deo za odgovor, njega sredjujem posle 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 | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 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 | 12 ms | 1236 KB | Output is correct |
7 | Correct | 175 ms | 22056 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 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 | 12 ms | 1236 KB | Output is correct |
7 | Correct | 175 ms | 22056 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 11 ms | 1236 KB | Output is correct |
13 | Correct | 187 ms | 22160 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 3 ms | 724 KB | Output is correct |
17 | Correct | 71 ms | 8296 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 51 ms | 5796 KB | Output is correct |
21 | Correct | 202 ms | 22116 KB | Output is correct |
22 | Correct | 217 ms | 22116 KB | Output is correct |
23 | Correct | 186 ms | 22132 KB | Output is correct |
24 | Correct | 178 ms | 22220 KB | Output is correct |
25 | Correct | 75 ms | 8176 KB | Output is correct |
26 | Correct | 68 ms | 8296 KB | Output is correct |
27 | Correct | 184 ms | 22132 KB | Output is correct |
28 | Correct | 191 ms | 22264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 400 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 400 KB | Output is correct |
8 | Correct | 9 ms | 1400 KB | Output is correct |
9 | Correct | 211 ms | 23528 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 9 ms | 1364 KB | Output is correct |
13 | Correct | 192 ms | 23852 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Incorrect | 9 ms | 1308 KB | Answer gives possible 1 while actual possible 0 |
17 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 50 ms | 5860 KB | Output is correct |
5 | Correct | 204 ms | 22152 KB | Output is correct |
6 | Correct | 175 ms | 22068 KB | Output is correct |
7 | Correct | 191 ms | 22120 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 52 ms | 5868 KB | Output is correct |
10 | Correct | 231 ms | 24160 KB | Output is correct |
11 | Correct | 183 ms | 24032 KB | Output is correct |
12 | Correct | 212 ms | 24152 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 49 ms | 6348 KB | Output is correct |
17 | Correct | 203 ms | 24124 KB | Output is correct |
18 | Correct | 172 ms | 24032 KB | Output is correct |
19 | Correct | 183 ms | 24024 KB | Output is correct |
20 | Correct | 175 ms | 24156 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 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 | 12 ms | 1236 KB | Output is correct |
7 | Correct | 175 ms | 22056 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 11 ms | 1236 KB | Output is correct |
13 | Correct | 187 ms | 22160 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 3 ms | 724 KB | Output is correct |
17 | Correct | 71 ms | 8296 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 51 ms | 5796 KB | Output is correct |
21 | Correct | 202 ms | 22116 KB | Output is correct |
22 | Correct | 217 ms | 22116 KB | Output is correct |
23 | Correct | 186 ms | 22132 KB | Output is correct |
24 | Correct | 178 ms | 22220 KB | Output is correct |
25 | Correct | 75 ms | 8176 KB | Output is correct |
26 | Correct | 68 ms | 8296 KB | Output is correct |
27 | Correct | 184 ms | 22132 KB | Output is correct |
28 | Correct | 191 ms | 22264 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 400 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 400 KB | Output is correct |
36 | Correct | 9 ms | 1400 KB | Output is correct |
37 | Correct | 211 ms | 23528 KB | Output is correct |
38 | Correct | 1 ms | 340 KB | Output is correct |
39 | Correct | 1 ms | 340 KB | Output is correct |
40 | Correct | 9 ms | 1364 KB | Output is correct |
41 | Correct | 192 ms | 23852 KB | Output is correct |
42 | Correct | 1 ms | 340 KB | Output is correct |
43 | Correct | 1 ms | 340 KB | Output is correct |
44 | Incorrect | 9 ms | 1308 KB | Answer gives possible 1 while actual possible 0 |
45 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 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 | 12 ms | 1236 KB | Output is correct |
7 | Correct | 175 ms | 22056 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 11 ms | 1236 KB | Output is correct |
13 | Correct | 187 ms | 22160 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 3 ms | 724 KB | Output is correct |
17 | Correct | 71 ms | 8296 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 51 ms | 5796 KB | Output is correct |
21 | Correct | 202 ms | 22116 KB | Output is correct |
22 | Correct | 217 ms | 22116 KB | Output is correct |
23 | Correct | 186 ms | 22132 KB | Output is correct |
24 | Correct | 178 ms | 22220 KB | Output is correct |
25 | Correct | 75 ms | 8176 KB | Output is correct |
26 | Correct | 68 ms | 8296 KB | Output is correct |
27 | Correct | 184 ms | 22132 KB | Output is correct |
28 | Correct | 191 ms | 22264 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 400 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 400 KB | Output is correct |
36 | Correct | 9 ms | 1400 KB | Output is correct |
37 | Correct | 211 ms | 23528 KB | Output is correct |
38 | Correct | 1 ms | 340 KB | Output is correct |
39 | Correct | 1 ms | 340 KB | Output is correct |
40 | Correct | 9 ms | 1364 KB | Output is correct |
41 | Correct | 192 ms | 23852 KB | Output is correct |
42 | Correct | 1 ms | 340 KB | Output is correct |
43 | Correct | 1 ms | 340 KB | Output is correct |
44 | Incorrect | 9 ms | 1308 KB | Answer gives possible 1 while actual possible 0 |
45 | Halted | 0 ms | 0 KB | - |