# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955723 | 2024-03-31T11:18:13 Z | Alexabcde1 | Connecting Supertrees (IOI20_supertrees) | C++14 | 192 ms | 31536 KB |
#include <vector> #include <cstdio> #include<bits/stdc++.h> using namespace std; void build(std::vector<std::vector<int>> b); vector<long long> bg[1005],sg[1005]; vector<long long> kg; long long a[1005],a2[1005],ans[1005][1005]; long long find(long long x){ if (a[x]==x) return x; else return a[x]=find(a[x]); } long long find2(long long x){ if (a2[x]==x) return x; else return a2[x]=find2(a2[x]); } void link(long long x,long long y){ ans[x][y]=1; ans[y][x]=1; return; } int construct(std::vector<std::vector<int>> p) { long long n=p.size(); for (int i=0;i<n;i++) a[i]=i; for (int i=0;i<n;i++) a2[i]=i; for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ if (p[i][j]==3) return 0; if (p[i][j]) { long long x=find(a[i]); long long y=find(a[j]); if (x!=y){ a[x]=y; } } } } for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ if (p[i][j]==0) { long long x=find(a[i]); long long y=find(a[j]); if (x==y) return 0; } } } for (int i=0;i<n;i++){ bg[find(i)].push_back(i); } for (int i=0;i<n;i++){ for (int ii=0;ii<bg[i].size();ii++){ for (int jj=0;jj<bg[i].size();jj++){ long long u=bg[i][ii]; long long v=bg[i][jj]; long long x=find2(u); long long y=find2(v); if (p[u][v]==1){ a2[x]=y; } } } for (int ii=0;ii<bg[i].size();ii++){ for (int jj=0;jj<bg[i].size();jj++){ long long u=bg[i][ii]; long long v=bg[i][jj]; long long x=find2(u); long long y=find2(v); if (p[u][v]==2){ if (x==y) return 0; } } } for (int ii=0;ii<bg[i].size();ii++){ sg[find2(bg[i][ii])].push_back(bg[i][ii]); //cout<<bg[i][ii]<<" "<<find2(bg[i][ii])<<endl; } kg.clear(); for (int ii=0;ii<bg[i].size();ii++){ long long node=bg[i][ii]; if (sg[node].size()){ for (int jj=0;jj<sg[node].size()-1;jj++){ link(sg[node][jj],sg[node][jj+1]); } kg.push_back(node); } } for (int i=0;i<kg.size();i++){ if (kg.size()>1) link(kg[i],kg[(i+1)%kg.size()]); } } vector<vector<int> > anss; for (int i=0;i<n;i++){ vector<int> tmp; for (int j=0;j<n;j++) tmp.push_back(ans[i][j]); anss.push_back(tmp); } build(anss); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 8 ms | 3416 KB | Output is correct |
7 | Correct | 165 ms | 31100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 8 ms | 3416 KB | Output is correct |
7 | Correct | 165 ms | 31100 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1368 KB | Output is correct |
13 | Correct | 160 ms | 24496 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 856 KB | Output is correct |
17 | Correct | 70 ms | 10292 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 40 ms | 10580 KB | Output is correct |
21 | Correct | 158 ms | 31244 KB | Output is correct |
22 | Correct | 156 ms | 31056 KB | Output is correct |
23 | Correct | 165 ms | 31144 KB | Output is correct |
24 | Correct | 165 ms | 30292 KB | Output is correct |
25 | Correct | 65 ms | 10556 KB | Output is correct |
26 | Correct | 59 ms | 10216 KB | Output is correct |
27 | Correct | 166 ms | 31060 KB | Output is correct |
28 | Correct | 175 ms | 30644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 0 ms | 348 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 | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 40 ms | 10432 KB | Output is correct |
5 | Correct | 192 ms | 31152 KB | Output is correct |
6 | Correct | 156 ms | 31060 KB | Output is correct |
7 | Correct | 174 ms | 31176 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 39 ms | 10560 KB | Output is correct |
10 | Correct | 157 ms | 31276 KB | Output is correct |
11 | Correct | 156 ms | 31536 KB | Output is correct |
12 | Correct | 162 ms | 31164 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 41 ms | 10532 KB | Output is correct |
17 | Correct | 159 ms | 31316 KB | Output is correct |
18 | Correct | 168 ms | 31316 KB | Output is correct |
19 | Correct | 157 ms | 31312 KB | Output is correct |
20 | Correct | 156 ms | 30380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 8 ms | 3416 KB | Output is correct |
7 | Correct | 165 ms | 31100 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1368 KB | Output is correct |
13 | Correct | 160 ms | 24496 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 856 KB | Output is correct |
17 | Correct | 70 ms | 10292 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 40 ms | 10580 KB | Output is correct |
21 | Correct | 158 ms | 31244 KB | Output is correct |
22 | Correct | 156 ms | 31056 KB | Output is correct |
23 | Correct | 165 ms | 31144 KB | Output is correct |
24 | Correct | 165 ms | 30292 KB | Output is correct |
25 | Correct | 65 ms | 10556 KB | Output is correct |
26 | Correct | 59 ms | 10216 KB | Output is correct |
27 | Correct | 166 ms | 31060 KB | Output is correct |
28 | Correct | 175 ms | 30644 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Incorrect | 0 ms | 348 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 8 ms | 3416 KB | Output is correct |
7 | Correct | 165 ms | 31100 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1368 KB | Output is correct |
13 | Correct | 160 ms | 24496 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 856 KB | Output is correct |
17 | Correct | 70 ms | 10292 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 40 ms | 10580 KB | Output is correct |
21 | Correct | 158 ms | 31244 KB | Output is correct |
22 | Correct | 156 ms | 31056 KB | Output is correct |
23 | Correct | 165 ms | 31144 KB | Output is correct |
24 | Correct | 165 ms | 30292 KB | Output is correct |
25 | Correct | 65 ms | 10556 KB | Output is correct |
26 | Correct | 59 ms | 10216 KB | Output is correct |
27 | Correct | 166 ms | 31060 KB | Output is correct |
28 | Correct | 175 ms | 30644 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Incorrect | 0 ms | 348 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |