답안 #828648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
828648 2023-08-17T13:10:30 Z Mularstyle 슈퍼트리 잇기 (IOI20_supertrees) C++14
100 / 100
174 ms 24192 KB
#include "supertrees.h"
#include <vector>
#include<bits/stdc++.h>
#define ll long long

using namespace std;
int C1[1008],C2[1008],P[1008];
bool vis[1008];
//int V[1008][1008];
vector<std::vector<int>> A;
void added(int u,int v)
{
    if(u==-1||v==-1)
        return;
    if(u==v)
        return;
    A[u][v]=1;
    A[v][u]=1;
    return;
}


int construct(std::vector<std::vector<int>> p) {
	int n = p.size();

	int cnt=0;
    A.resize(n);
    for(int i=0;i<n;i++)
    {
        A[i].resize(n);
        for(int j=0;j<n;j++)
            A[i][j]=0;
    }
    for(int i=0;i<n;i++)
    {
        if(C1[i]==0)cnt++;
        else continue;
        for(int j=0;j<n;j++)
        {
            if(p[i][j])
                C1[j]=cnt;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if((C1[i]==C1[j])^(p[i][j]!=0))
                return 0;//impos
            if(p[i][j]==3)
                return 0;//impos
        }
    }
    vector<int> com;
    cnt=0;
    for(int i=0;i<n;i++)
        P[i]=-1;

    for(int i=0;i<n;i++)
    {
        if(C2[i]==0)cnt++;
        else continue;
        com.push_back(i);
        for(int j=0;j<n;j++)
        {
            if(p[i][j]==1)
            {
                P[j]=i;
                C2[j]=cnt;
            }
        }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)continue;
            if((p[i][j]==1)^(C2[i]==C2[j]))
                return 0;//impos
        }
    }

    for(int i=0;i<n;i++)
    {
        added(i,P[i]);
    }

    for(auto c:com)
    {
        vector<int> sub;
        if(vis[c])continue;
        for(auto s:com)
        {
            if(C1[c]==C1[s]&&!vis[s])
                sub.push_back(s);
        }

    for(auto s:sub)
        vis[s]=true;
    int siz=sub.size();
    if(siz==2)
        return 0;//impos
    if(siz>1)
    {
        for(int i=0;i<siz;i++)
            added(sub[i],sub[(i+1)%siz]);
    }
    }
    build(A);
    return 1;//possible
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1276 KB Output is correct
7 Correct 150 ms 23888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1276 KB Output is correct
7 Correct 150 ms 23888 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1256 KB Output is correct
13 Correct 161 ms 23908 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 72 ms 14072 KB Output is correct
18 Correct 0 ms 304 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 42 ms 6264 KB Output is correct
21 Correct 153 ms 24012 KB Output is correct
22 Correct 160 ms 23968 KB Output is correct
23 Correct 174 ms 23932 KB Output is correct
24 Correct 157 ms 24044 KB Output is correct
25 Correct 65 ms 14032 KB Output is correct
26 Correct 66 ms 14068 KB Output is correct
27 Correct 160 ms 24000 KB Output is correct
28 Correct 159 ms 23932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 304 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 6 ms 1208 KB Output is correct
9 Correct 149 ms 23932 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 7 ms 1140 KB Output is correct
13 Correct 148 ms 23932 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 64 ms 14068 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 38 ms 6180 KB Output is correct
22 Correct 152 ms 24012 KB Output is correct
23 Correct 150 ms 23940 KB Output is correct
24 Correct 156 ms 24012 KB Output is correct
25 Correct 64 ms 14084 KB Output is correct
26 Correct 62 ms 14080 KB Output is correct
27 Correct 153 ms 24192 KB Output is correct
28 Correct 157 ms 23988 KB Output is correct
29 Correct 64 ms 14080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 46 ms 6252 KB Output is correct
5 Correct 150 ms 23940 KB Output is correct
6 Correct 158 ms 24012 KB Output is correct
7 Correct 154 ms 23924 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 38 ms 6264 KB Output is correct
10 Correct 151 ms 24004 KB Output is correct
11 Correct 150 ms 23988 KB Output is correct
12 Correct 154 ms 23928 KB Output is correct
13 Correct 0 ms 308 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 38 ms 6208 KB Output is correct
17 Correct 151 ms 23884 KB Output is correct
18 Correct 151 ms 23884 KB Output is correct
19 Correct 150 ms 24080 KB Output is correct
20 Correct 157 ms 23884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1276 KB Output is correct
7 Correct 150 ms 23888 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1256 KB Output is correct
13 Correct 161 ms 23908 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 72 ms 14072 KB Output is correct
18 Correct 0 ms 304 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 42 ms 6264 KB Output is correct
21 Correct 153 ms 24012 KB Output is correct
22 Correct 160 ms 23968 KB Output is correct
23 Correct 174 ms 23932 KB Output is correct
24 Correct 157 ms 24044 KB Output is correct
25 Correct 65 ms 14032 KB Output is correct
26 Correct 66 ms 14068 KB Output is correct
27 Correct 160 ms 24000 KB Output is correct
28 Correct 159 ms 23932 KB Output is correct
29 Correct 1 ms 304 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 212 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 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 6 ms 1208 KB Output is correct
37 Correct 149 ms 23932 KB Output is correct
38 Correct 1 ms 296 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 7 ms 1140 KB Output is correct
41 Correct 148 ms 23932 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 3 ms 852 KB Output is correct
45 Correct 64 ms 14068 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 304 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 38 ms 6180 KB Output is correct
50 Correct 152 ms 24012 KB Output is correct
51 Correct 150 ms 23940 KB Output is correct
52 Correct 156 ms 24012 KB Output is correct
53 Correct 64 ms 14084 KB Output is correct
54 Correct 62 ms 14080 KB Output is correct
55 Correct 153 ms 24192 KB Output is correct
56 Correct 157 ms 23988 KB Output is correct
57 Correct 64 ms 14080 KB Output is correct
58 Correct 0 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 65 ms 14076 KB Output is correct
62 Correct 0 ms 304 KB Output is correct
63 Correct 0 ms 212 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 38 ms 6260 KB Output is correct
66 Correct 61 ms 14076 KB Output is correct
67 Correct 62 ms 14088 KB Output is correct
68 Correct 61 ms 14008 KB Output is correct
69 Correct 64 ms 14080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1276 KB Output is correct
7 Correct 150 ms 23888 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1256 KB Output is correct
13 Correct 161 ms 23908 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 72 ms 14072 KB Output is correct
18 Correct 0 ms 304 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 42 ms 6264 KB Output is correct
21 Correct 153 ms 24012 KB Output is correct
22 Correct 160 ms 23968 KB Output is correct
23 Correct 174 ms 23932 KB Output is correct
24 Correct 157 ms 24044 KB Output is correct
25 Correct 65 ms 14032 KB Output is correct
26 Correct 66 ms 14068 KB Output is correct
27 Correct 160 ms 24000 KB Output is correct
28 Correct 159 ms 23932 KB Output is correct
29 Correct 1 ms 304 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 212 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 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 6 ms 1208 KB Output is correct
37 Correct 149 ms 23932 KB Output is correct
38 Correct 1 ms 296 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 7 ms 1140 KB Output is correct
41 Correct 148 ms 23932 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 3 ms 852 KB Output is correct
45 Correct 64 ms 14068 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 304 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 38 ms 6180 KB Output is correct
50 Correct 152 ms 24012 KB Output is correct
51 Correct 150 ms 23940 KB Output is correct
52 Correct 156 ms 24012 KB Output is correct
53 Correct 64 ms 14084 KB Output is correct
54 Correct 62 ms 14080 KB Output is correct
55 Correct 153 ms 24192 KB Output is correct
56 Correct 157 ms 23988 KB Output is correct
57 Correct 64 ms 14080 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 46 ms 6252 KB Output is correct
62 Correct 150 ms 23940 KB Output is correct
63 Correct 158 ms 24012 KB Output is correct
64 Correct 154 ms 23924 KB Output is correct
65 Correct 0 ms 304 KB Output is correct
66 Correct 38 ms 6264 KB Output is correct
67 Correct 151 ms 24004 KB Output is correct
68 Correct 150 ms 23988 KB Output is correct
69 Correct 154 ms 23928 KB Output is correct
70 Correct 0 ms 308 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 0 ms 212 KB Output is correct
73 Correct 38 ms 6208 KB Output is correct
74 Correct 151 ms 23884 KB Output is correct
75 Correct 151 ms 23884 KB Output is correct
76 Correct 150 ms 24080 KB Output is correct
77 Correct 157 ms 23884 KB Output is correct
78 Correct 0 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 65 ms 14076 KB Output is correct
82 Correct 0 ms 304 KB Output is correct
83 Correct 0 ms 212 KB Output is correct
84 Correct 0 ms 212 KB Output is correct
85 Correct 38 ms 6260 KB Output is correct
86 Correct 61 ms 14076 KB Output is correct
87 Correct 62 ms 14088 KB Output is correct
88 Correct 61 ms 14008 KB Output is correct
89 Correct 64 ms 14080 KB Output is correct
90 Correct 0 ms 308 KB Output is correct
91 Correct 0 ms 212 KB Output is correct
92 Correct 3 ms 852 KB Output is correct
93 Correct 63 ms 14084 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 1 ms 212 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 16 ms 3660 KB Output is correct
98 Correct 95 ms 13992 KB Output is correct
99 Correct 61 ms 14028 KB Output is correct
100 Correct 66 ms 14080 KB Output is correct
101 Correct 62 ms 14072 KB Output is correct
102 Correct 61 ms 14084 KB Output is correct
103 Correct 61 ms 14084 KB Output is correct
104 Correct 62 ms 14076 KB Output is correct
105 Correct 65 ms 14084 KB Output is correct