Submission #734894

# Submission time Handle Problem Language Result Execution time Memory
734894 2023-05-03T08:21:59 Z Elvin_Fritl Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
198 ms 24096 KB
//#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;

void build(vector<vector<int> > b);

bool vis[1002];
int construct(vector<vector<int> > p) {
    int n = (int)p.size();
    vector<vector<int> > ans(n);
    for(int i=0;i<n;i++) ans[i].resize(n);
    for(int i=0;i<n;i++){
        if(vis[i]) continue;
        vis[i] = 1;
        vector<int> c1, c2;
        for(int j=i+1;j<n;j++){
            if(p[i][j] == 1){
                c1.push_back(j);
                vis[j] = 1;
            }
        }
        for(int j=i+1;j<n;j++){
            if(p[i][j] == 2){
                c2.push_back(j);
                vis[j] = 1;
            }
        }

        for(int j=i+1;j<n;j++){
            if(vis[j]) continue;
            for(int k=0;k<(int)c1.size();k++){
                if(p[j][c1[k]] != 0) return 0;
            }
            for(int k=0;k<(int)c2.size();k++){
                if(p[j][c2[k]] != 0) return 0;
            }
        }

        for(int j=0;j<(int)c1.size();j++){
            for(int k=0;k<(int)c1.size();k++){
                if(j == k) continue;
                if(p[c1[j]][c1[k]] != 1) return 0;
            }
        }
        for(int j=0;j<(int)c1.size();j++){
            for(int k=0;k<(int)c2.size();k++){
                if(p[c1[j]][c2[k]] != 2) return 0;
            }
        }

        for(int j=0;j<(int)c2.size();j++){
            for(int k=0;k<(int)c2.size();k++){
                if(j == k) continue;
                if(p[c2[j]][c2[k]] != 2) return 2;
            }
        }

        for(int j=0;j<(int)c1.size();j++){
            ans[i][c1[j]] = 1;
            ans[c1[j]][i] = 1;
        }

        if((int)c2.size() == 1) return 0;
        else if((int)c2.size() > 1){
            ans[i][c2[0]] = 1;
            ans[c2[0]][i] = 1;

            ans[i][c2[c2.size()-1]] = 1;
            ans[c2[c2.size()-1]][i] = 1;
            for(int j=0;j<(int)c2.size()-1;j++){
                ans[c2[j]][c2[j+1]] = 1;
                ans[c2[j+1]][c2[j]] = 1;
            }
        }
    }

    build(ans);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1236 KB Output is correct
7 Correct 195 ms 22428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1236 KB Output is correct
7 Correct 195 ms 22428 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1208 KB Output is correct
13 Correct 185 ms 22524 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 85 ms 14064 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 50 ms 6188 KB Output is correct
21 Correct 195 ms 24096 KB Output is correct
22 Correct 179 ms 23920 KB Output is correct
23 Correct 194 ms 23884 KB Output is correct
24 Correct 180 ms 23956 KB Output is correct
25 Correct 77 ms 14068 KB Output is correct
26 Correct 73 ms 14072 KB Output is correct
27 Correct 188 ms 23888 KB Output is correct
28 Correct 188 ms 23920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 8 ms 1208 KB Output is correct
9 Correct 190 ms 22320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 9 ms 1208 KB Output is correct
13 Correct 187 ms 22572 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 85 ms 13524 KB Output is correct
18 Incorrect 1 ms 296 KB WA in grader: Invalid return value of construct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 47 ms 5952 KB Output is correct
5 Correct 198 ms 22520 KB Output is correct
6 Correct 194 ms 22496 KB Output is correct
7 Correct 195 ms 22484 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 45 ms 6104 KB Output is correct
10 Correct 178 ms 24044 KB Output is correct
11 Correct 183 ms 23880 KB Output is correct
12 Correct 189 ms 23928 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Incorrect 17 ms 3668 KB WA in grader: Invalid return value of construct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1236 KB Output is correct
7 Correct 195 ms 22428 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1208 KB Output is correct
13 Correct 185 ms 22524 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 85 ms 14064 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 50 ms 6188 KB Output is correct
21 Correct 195 ms 24096 KB Output is correct
22 Correct 179 ms 23920 KB Output is correct
23 Correct 194 ms 23884 KB Output is correct
24 Correct 180 ms 23956 KB Output is correct
25 Correct 77 ms 14068 KB Output is correct
26 Correct 73 ms 14072 KB Output is correct
27 Correct 188 ms 23888 KB Output is correct
28 Correct 188 ms 23920 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 300 KB Output is correct
35 Correct 1 ms 300 KB Output is correct
36 Correct 8 ms 1208 KB Output is correct
37 Correct 190 ms 22320 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 9 ms 1208 KB Output is correct
41 Correct 187 ms 22572 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 4 ms 852 KB Output is correct
45 Correct 85 ms 13524 KB Output is correct
46 Incorrect 1 ms 296 KB WA in grader: Invalid return value of construct
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1236 KB Output is correct
7 Correct 195 ms 22428 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1208 KB Output is correct
13 Correct 185 ms 22524 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 85 ms 14064 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 50 ms 6188 KB Output is correct
21 Correct 195 ms 24096 KB Output is correct
22 Correct 179 ms 23920 KB Output is correct
23 Correct 194 ms 23884 KB Output is correct
24 Correct 180 ms 23956 KB Output is correct
25 Correct 77 ms 14068 KB Output is correct
26 Correct 73 ms 14072 KB Output is correct
27 Correct 188 ms 23888 KB Output is correct
28 Correct 188 ms 23920 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 300 KB Output is correct
35 Correct 1 ms 300 KB Output is correct
36 Correct 8 ms 1208 KB Output is correct
37 Correct 190 ms 22320 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 9 ms 1208 KB Output is correct
41 Correct 187 ms 22572 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 4 ms 852 KB Output is correct
45 Correct 85 ms 13524 KB Output is correct
46 Incorrect 1 ms 296 KB WA in grader: Invalid return value of construct
47 Halted 0 ms 0 KB -