Submission #832968

# Submission time Handle Problem Language Result Execution time Memory
832968 2023-08-21T17:26:20 Z Marco_Escandon Connecting Supertrees (IOI20_supertrees) C++17
100 / 100
207 ms 24160 KB
#include "supertrees.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
struct st
{
    vector<int> cad;
    int findf(int a)
    {
        if(a==cad[a])return a;
        else return cad[a]=findf(cad[a]);
    }
    void unionf(int a, int b){
        a=findf(a);
        b=findf(b);
        if(a!=b){
            cad[a]=b;
        }
    }
    st(int n){
        cad.resize(2*n);
        for(int i=0; i<cad.size(); i++)
            cad[i]=i;
    }
};
int construct(std::vector<std::vector<int>> cad) {
    int n = cad.size();
    std::vector<std::vector<int>> answer(n,vector<int>(n,0LL));
    st asdfg(n+1);
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            if(cad[i][j]==3)
                return 0;
            if(cad[i][j]!=0&&i!=j)
                asdfg.unionf(i,j);
        }

    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            if(cad[i][j]==0&&asdfg.findf(i)==asdfg.findf(j)&&i!=j)
                return 0;
    st asd(n+1);
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            if(cad[i][j]==1&&i!=j)
                asd.unionf(i,j);
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            if(cad[i][j]==2&&asd.findf(i)==asd.findf(j)&&i!=j)
                return 0;
            if(asd.cad[i]==j&&i!=j)
            {
                answer[i][j]=1;
                answer[j][i]=1;
            }
        }
    int v2[n+1]={ };
    int v[n+1]={ };
    for(int j=0; j<n; j++)
    {
        int p=asd.findf(j);
        if(v[p]==0)
        {
            int pg=p;
            v[p]=1;
            for(int i=j+1; i<n; i++)
            {
                if(v[asd.findf(i)]==0&&asdfg.findf(i)==asdfg.findf(p))
                {
                    answer[asd.findf(i)][p]=1;
                    answer[p][asd.findf(i)]=1;
                    p=asd.findf(i);
                    v[asd.findf(i)]=1;
                    v2[asdfg.findf(i)]++;
                }
            }
            if(pg!=p)
            {
                answer[pg][p]=1;
                answer[p][pg]=1;
            }
        }


    }

    for(int i=0; i<n; i++)
    {
        if(v2[asdfg.findf(i)]==1)
            return 0;
    }
    build(answer);
    return 1;
}

Compilation message

supertrees.cpp: In constructor 'st::st(int)':
supertrees.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int i=0; i<cad.size(); i++)
      |                      ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 1184 KB Output is correct
7 Correct 164 ms 23980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 1184 KB Output is correct
7 Correct 164 ms 23980 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Correct 155 ms 23384 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 71 ms 14064 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 40 ms 6264 KB Output is correct
21 Correct 158 ms 23932 KB Output is correct
22 Correct 161 ms 23980 KB Output is correct
23 Correct 181 ms 23952 KB Output is correct
24 Correct 157 ms 23924 KB Output is correct
25 Correct 70 ms 14084 KB Output is correct
26 Correct 63 ms 13996 KB Output is correct
27 Correct 207 ms 23932 KB Output is correct
28 Correct 157 ms 23952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 7 ms 1228 KB Output is correct
9 Correct 154 ms 23932 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Correct 165 ms 24016 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 260 KB Output is correct
16 Correct 3 ms 828 KB Output is correct
17 Correct 71 ms 14068 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 40 ms 6244 KB Output is correct
22 Correct 170 ms 23940 KB Output is correct
23 Correct 155 ms 23896 KB Output is correct
24 Correct 164 ms 23968 KB Output is correct
25 Correct 67 ms 14068 KB Output is correct
26 Correct 64 ms 14084 KB Output is correct
27 Correct 157 ms 23924 KB Output is correct
28 Correct 161 ms 23920 KB Output is correct
29 Correct 67 ms 14068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 41 ms 6196 KB Output is correct
5 Correct 159 ms 23976 KB Output is correct
6 Correct 159 ms 23936 KB Output is correct
7 Correct 170 ms 24160 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 40 ms 6140 KB Output is correct
10 Correct 158 ms 23924 KB Output is correct
11 Correct 167 ms 23952 KB Output is correct
12 Correct 197 ms 23936 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 300 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 40 ms 6348 KB Output is correct
17 Correct 160 ms 23936 KB Output is correct
18 Correct 175 ms 24012 KB Output is correct
19 Correct 160 ms 23912 KB Output is correct
20 Correct 158 ms 23936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 1184 KB Output is correct
7 Correct 164 ms 23980 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Correct 155 ms 23384 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 71 ms 14064 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 40 ms 6264 KB Output is correct
21 Correct 158 ms 23932 KB Output is correct
22 Correct 161 ms 23980 KB Output is correct
23 Correct 181 ms 23952 KB Output is correct
24 Correct 157 ms 23924 KB Output is correct
25 Correct 70 ms 14084 KB Output is correct
26 Correct 63 ms 13996 KB Output is correct
27 Correct 207 ms 23932 KB Output is correct
28 Correct 157 ms 23952 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 304 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 300 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 304 KB Output is correct
36 Correct 7 ms 1228 KB Output is correct
37 Correct 154 ms 23932 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 7 ms 1236 KB Output is correct
41 Correct 165 ms 24016 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 260 KB Output is correct
44 Correct 3 ms 828 KB Output is correct
45 Correct 71 ms 14068 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 40 ms 6244 KB Output is correct
50 Correct 170 ms 23940 KB Output is correct
51 Correct 155 ms 23896 KB Output is correct
52 Correct 164 ms 23968 KB Output is correct
53 Correct 67 ms 14068 KB Output is correct
54 Correct 64 ms 14084 KB Output is correct
55 Correct 157 ms 23924 KB Output is correct
56 Correct 161 ms 23920 KB Output is correct
57 Correct 67 ms 14068 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 3 ms 852 KB Output is correct
61 Correct 69 ms 14080 KB Output is correct
62 Correct 0 ms 296 KB Output is correct
63 Correct 0 ms 304 KB Output is correct
64 Correct 0 ms 300 KB Output is correct
65 Correct 40 ms 6260 KB Output is correct
66 Correct 65 ms 13988 KB Output is correct
67 Correct 65 ms 14080 KB Output is correct
68 Correct 65 ms 14208 KB Output is correct
69 Correct 67 ms 14064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 1184 KB Output is correct
7 Correct 164 ms 23980 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Correct 155 ms 23384 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 71 ms 14064 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 40 ms 6264 KB Output is correct
21 Correct 158 ms 23932 KB Output is correct
22 Correct 161 ms 23980 KB Output is correct
23 Correct 181 ms 23952 KB Output is correct
24 Correct 157 ms 23924 KB Output is correct
25 Correct 70 ms 14084 KB Output is correct
26 Correct 63 ms 13996 KB Output is correct
27 Correct 207 ms 23932 KB Output is correct
28 Correct 157 ms 23952 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 304 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 300 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 304 KB Output is correct
36 Correct 7 ms 1228 KB Output is correct
37 Correct 154 ms 23932 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 7 ms 1236 KB Output is correct
41 Correct 165 ms 24016 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 260 KB Output is correct
44 Correct 3 ms 828 KB Output is correct
45 Correct 71 ms 14068 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 40 ms 6244 KB Output is correct
50 Correct 170 ms 23940 KB Output is correct
51 Correct 155 ms 23896 KB Output is correct
52 Correct 164 ms 23968 KB Output is correct
53 Correct 67 ms 14068 KB Output is correct
54 Correct 64 ms 14084 KB Output is correct
55 Correct 157 ms 23924 KB Output is correct
56 Correct 161 ms 23920 KB Output is correct
57 Correct 67 ms 14068 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 41 ms 6196 KB Output is correct
62 Correct 159 ms 23976 KB Output is correct
63 Correct 159 ms 23936 KB Output is correct
64 Correct 170 ms 24160 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 40 ms 6140 KB Output is correct
67 Correct 158 ms 23924 KB Output is correct
68 Correct 167 ms 23952 KB Output is correct
69 Correct 197 ms 23936 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 300 KB Output is correct
72 Correct 0 ms 300 KB Output is correct
73 Correct 40 ms 6348 KB Output is correct
74 Correct 160 ms 23936 KB Output is correct
75 Correct 175 ms 24012 KB Output is correct
76 Correct 160 ms 23912 KB Output is correct
77 Correct 158 ms 23936 KB Output is correct
78 Correct 1 ms 212 KB Output is correct
79 Correct 0 ms 212 KB Output is correct
80 Correct 3 ms 852 KB Output is correct
81 Correct 69 ms 14080 KB Output is correct
82 Correct 0 ms 296 KB Output is correct
83 Correct 0 ms 304 KB Output is correct
84 Correct 0 ms 300 KB Output is correct
85 Correct 40 ms 6260 KB Output is correct
86 Correct 65 ms 13988 KB Output is correct
87 Correct 65 ms 14080 KB Output is correct
88 Correct 65 ms 14208 KB Output is correct
89 Correct 67 ms 14064 KB Output is correct
90 Correct 0 ms 296 KB Output is correct
91 Correct 1 ms 212 KB Output is correct
92 Correct 3 ms 852 KB Output is correct
93 Correct 65 ms 14076 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 0 ms 212 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 19 ms 3712 KB Output is correct
98 Correct 64 ms 14028 KB Output is correct
99 Correct 64 ms 14068 KB Output is correct
100 Correct 61 ms 13996 KB Output is correct
101 Correct 62 ms 14080 KB Output is correct
102 Correct 62 ms 14064 KB Output is correct
103 Correct 61 ms 14076 KB Output is correct
104 Correct 62 ms 14064 KB Output is correct
105 Correct 69 ms 14072 KB Output is correct