답안 #825139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
825139 2023-08-14T14:44:45 Z Marco_Escandon 슈퍼트리 잇기 (IOI20_supertrees) C++14
96 / 100
166 ms 24060 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]!=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++)
      |                      ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 8 ms 1232 KB Output is correct
7 Correct 157 ms 23976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 8 ms 1232 KB Output is correct
7 Correct 157 ms 23976 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1244 KB Output is correct
13 Correct 151 ms 23924 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 68 ms 14004 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 153 ms 23936 KB Output is correct
22 Correct 151 ms 23968 KB Output is correct
23 Correct 156 ms 23972 KB Output is correct
24 Correct 155 ms 24060 KB Output is correct
25 Correct 61 ms 14028 KB Output is correct
26 Correct 59 ms 14000 KB Output is correct
27 Correct 166 ms 23936 KB Output is correct
28 Correct 155 ms 24012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 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 212 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 6 ms 1180 KB Output is correct
9 Correct 149 ms 24028 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 8 ms 1228 KB Output is correct
13 Correct 153 ms 23928 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 72 ms 14080 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 260 KB Output is correct
21 Correct 42 ms 6248 KB Output is correct
22 Correct 154 ms 23936 KB Output is correct
23 Correct 152 ms 23924 KB Output is correct
24 Correct 155 ms 24012 KB Output is correct
25 Correct 63 ms 14076 KB Output is correct
26 Correct 60 ms 14028 KB Output is correct
27 Correct 163 ms 23920 KB Output is correct
28 Correct 160 ms 23976 KB Output is correct
29 Correct 65 ms 14068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 38 ms 6220 KB Output is correct
5 Correct 153 ms 23984 KB Output is correct
6 Correct 153 ms 23920 KB Output is correct
7 Correct 155 ms 23932 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 46 ms 6136 KB Output is correct
10 Correct 153 ms 23920 KB Output is correct
11 Correct 160 ms 23940 KB Output is correct
12 Correct 158 ms 23936 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 39 ms 6260 KB Output is correct
17 Correct 153 ms 23924 KB Output is correct
18 Correct 164 ms 23984 KB Output is correct
19 Correct 152 ms 23928 KB Output is correct
20 Correct 150 ms 24012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 8 ms 1232 KB Output is correct
7 Correct 157 ms 23976 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1244 KB Output is correct
13 Correct 151 ms 23924 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 68 ms 14004 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 153 ms 23936 KB Output is correct
22 Correct 151 ms 23968 KB Output is correct
23 Correct 156 ms 23972 KB Output is correct
24 Correct 155 ms 24060 KB Output is correct
25 Correct 61 ms 14028 KB Output is correct
26 Correct 59 ms 14000 KB Output is correct
27 Correct 166 ms 23936 KB Output is correct
28 Correct 155 ms 24012 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 296 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 212 KB Output is correct
34 Correct 0 ms 304 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 6 ms 1180 KB Output is correct
37 Correct 149 ms 24028 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 8 ms 1228 KB Output is correct
41 Correct 153 ms 23928 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 72 ms 14080 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 260 KB Output is correct
49 Correct 42 ms 6248 KB Output is correct
50 Correct 154 ms 23936 KB Output is correct
51 Correct 152 ms 23924 KB Output is correct
52 Correct 155 ms 24012 KB Output is correct
53 Correct 63 ms 14076 KB Output is correct
54 Correct 60 ms 14028 KB Output is correct
55 Correct 163 ms 23920 KB Output is correct
56 Correct 160 ms 23976 KB Output is correct
57 Correct 65 ms 14068 KB Output is correct
58 Correct 0 ms 300 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 3 ms 852 KB Output is correct
61 Correct 73 ms 13992 KB Output is correct
62 Correct 0 ms 296 KB Output is correct
63 Correct 0 ms 212 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 39 ms 6248 KB Output is correct
66 Correct 59 ms 14060 KB Output is correct
67 Correct 61 ms 14072 KB Output is correct
68 Correct 59 ms 14064 KB Output is correct
69 Correct 64 ms 14068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 8 ms 1232 KB Output is correct
7 Correct 157 ms 23976 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1244 KB Output is correct
13 Correct 151 ms 23924 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 68 ms 14004 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 153 ms 23936 KB Output is correct
22 Correct 151 ms 23968 KB Output is correct
23 Correct 156 ms 23972 KB Output is correct
24 Correct 155 ms 24060 KB Output is correct
25 Correct 61 ms 14028 KB Output is correct
26 Correct 59 ms 14000 KB Output is correct
27 Correct 166 ms 23936 KB Output is correct
28 Correct 155 ms 24012 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 296 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 212 KB Output is correct
34 Correct 0 ms 304 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 6 ms 1180 KB Output is correct
37 Correct 149 ms 24028 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 8 ms 1228 KB Output is correct
41 Correct 153 ms 23928 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 72 ms 14080 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 260 KB Output is correct
49 Correct 42 ms 6248 KB Output is correct
50 Correct 154 ms 23936 KB Output is correct
51 Correct 152 ms 23924 KB Output is correct
52 Correct 155 ms 24012 KB Output is correct
53 Correct 63 ms 14076 KB Output is correct
54 Correct 60 ms 14028 KB Output is correct
55 Correct 163 ms 23920 KB Output is correct
56 Correct 160 ms 23976 KB Output is correct
57 Correct 65 ms 14068 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 38 ms 6220 KB Output is correct
62 Correct 153 ms 23984 KB Output is correct
63 Correct 153 ms 23920 KB Output is correct
64 Correct 155 ms 23932 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 46 ms 6136 KB Output is correct
67 Correct 153 ms 23920 KB Output is correct
68 Correct 160 ms 23940 KB Output is correct
69 Correct 158 ms 23936 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 1 ms 212 KB Output is correct
73 Correct 39 ms 6260 KB Output is correct
74 Correct 153 ms 23924 KB Output is correct
75 Correct 164 ms 23984 KB Output is correct
76 Correct 152 ms 23928 KB Output is correct
77 Correct 150 ms 24012 KB Output is correct
78 Correct 0 ms 300 KB Output is correct
79 Correct 1 ms 212 KB Output is correct
80 Correct 3 ms 852 KB Output is correct
81 Correct 73 ms 13992 KB Output is correct
82 Correct 0 ms 296 KB Output is correct
83 Correct 0 ms 212 KB Output is correct
84 Correct 0 ms 212 KB Output is correct
85 Correct 39 ms 6248 KB Output is correct
86 Correct 59 ms 14060 KB Output is correct
87 Correct 61 ms 14072 KB Output is correct
88 Correct 59 ms 14064 KB Output is correct
89 Correct 64 ms 14068 KB Output is correct
90 Correct 0 ms 212 KB Output is correct
91 Correct 0 ms 212 KB Output is correct
92 Correct 3 ms 852 KB Output is correct
93 Correct 67 ms 14080 KB Output is correct
94 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
95 Halted 0 ms 0 KB -