답안 #1014559

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014559 2024-07-05T06:56:18 Z Unforgettablepl 슈퍼트리 잇기 (IOI20_supertrees) C++17
96 / 100
145 ms 24200 KB
#include <bits/stdc++.h>
using namespace std;

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

int construct(std::vector<std::vector<int>> p) {
    int n = p.size();
    vector<vector<vector<int>>> components;
    for(int i=0;i<n;i++){
        int mycomponent = -1;
        for(int compo=0;compo<components.size();compo++){
            int shouldbe = p[i][components[compo][0][0]];
            shouldbe = min(shouldbe,1);
            if(shouldbe==1){
                if(mycomponent==-1)mycomponent=compo;
                else return 0;
            }
            for(auto&j:components[compo]){
                for(int&k:j){
                    if(shouldbe==0 and p[i][k]!=0)return 0;
                    if(shouldbe==1 and p[i][k]==0)return 0;
                }
            }
        }
        if(mycomponent==-1){
            components.push_back({{i}});
            continue;
        }
        int mychain = -1;
        for(int cha=0;cha<components[mycomponent].size();cha++){
            int shouldbe = p[i][components[mycomponent][cha][0]];
            if(shouldbe==1){
                if(mychain==-1)mychain=cha;
                else return 0;
            }
            for(int&j:components[mycomponent][cha]){
                if(shouldbe!=p[i][j])return 0;
            }
        }
        if(mychain==-1)components[mycomponent].push_back({i});
        else components[mycomponent][mychain].push_back(i);
    }
    vector<vector<int>> ans(n,vector<int>(n));
    for(auto&i:components){
        vector<int> heads;
        for(auto&j:i){
            heads.emplace_back(j[0]);
            for(int k=1;k<j.size();k++){
                ans[j[k-1]][j[k]]=ans[j[k]][j[k-1]]=true;
            }
        }
        if(heads.size()==2)return 0;
        if(heads.size()==1)continue;
        heads.emplace_back(heads.front());
        for(int j=1;j<heads.size();j++){
            ans[heads[j-1]][heads[j]]=ans[heads[j]][heads[j-1]]=true;
        }
    }
    build(ans);
    return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:11:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         for(int compo=0;compo<components.size();compo++){
      |                         ~~~~~^~~~~~~~~~~~~~~~~~
supertrees.cpp:30:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for(int cha=0;cha<components[mycomponent].size();cha++){
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
supertrees.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(int k=1;k<j.size();k++){
      |                         ~^~~~~~~~~
supertrees.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int j=1;j<heads.size();j++){
      |                     ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 5 ms 1184 KB Output is correct
7 Correct 113 ms 24148 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 5 ms 1184 KB Output is correct
7 Correct 113 ms 24148 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 5 ms 1368 KB Output is correct
13 Correct 117 ms 24200 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 58 ms 10120 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 29 ms 6280 KB Output is correct
21 Correct 129 ms 24144 KB Output is correct
22 Correct 112 ms 24144 KB Output is correct
23 Correct 120 ms 23920 KB Output is correct
24 Correct 123 ms 23976 KB Output is correct
25 Correct 50 ms 10248 KB Output is correct
26 Correct 49 ms 10172 KB Output is correct
27 Correct 145 ms 24148 KB Output is correct
28 Correct 113 ms 24144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 6 ms 1404 KB Output is correct
9 Correct 112 ms 24188 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 112 ms 24180 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 54 ms 10096 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 39 ms 6268 KB Output is correct
22 Correct 113 ms 24148 KB Output is correct
23 Correct 118 ms 24180 KB Output is correct
24 Correct 117 ms 24148 KB Output is correct
25 Correct 50 ms 14172 KB Output is correct
26 Correct 48 ms 10228 KB Output is correct
27 Correct 113 ms 23980 KB Output is correct
28 Correct 137 ms 24180 KB Output is correct
29 Correct 52 ms 14196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 35 ms 6224 KB Output is correct
5 Correct 113 ms 24072 KB Output is correct
6 Correct 123 ms 24072 KB Output is correct
7 Correct 121 ms 24108 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 28 ms 6440 KB Output is correct
10 Correct 113 ms 24148 KB Output is correct
11 Correct 104 ms 24144 KB Output is correct
12 Correct 107 ms 24140 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 29 ms 6420 KB Output is correct
17 Correct 108 ms 24140 KB Output is correct
18 Correct 103 ms 23944 KB Output is correct
19 Correct 111 ms 24144 KB Output is correct
20 Correct 114 ms 24148 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 5 ms 1184 KB Output is correct
7 Correct 113 ms 24148 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 5 ms 1368 KB Output is correct
13 Correct 117 ms 24200 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 58 ms 10120 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 29 ms 6280 KB Output is correct
21 Correct 129 ms 24144 KB Output is correct
22 Correct 112 ms 24144 KB Output is correct
23 Correct 120 ms 23920 KB Output is correct
24 Correct 123 ms 23976 KB Output is correct
25 Correct 50 ms 10248 KB Output is correct
26 Correct 49 ms 10172 KB Output is correct
27 Correct 145 ms 24148 KB Output is correct
28 Correct 113 ms 24144 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 6 ms 1404 KB Output is correct
37 Correct 112 ms 24188 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 5 ms 1372 KB Output is correct
41 Correct 112 ms 24180 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 3 ms 604 KB Output is correct
45 Correct 54 ms 10096 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 39 ms 6268 KB Output is correct
50 Correct 113 ms 24148 KB Output is correct
51 Correct 118 ms 24180 KB Output is correct
52 Correct 117 ms 24148 KB Output is correct
53 Correct 50 ms 14172 KB Output is correct
54 Correct 48 ms 10228 KB Output is correct
55 Correct 113 ms 23980 KB Output is correct
56 Correct 137 ms 24180 KB Output is correct
57 Correct 52 ms 14196 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 2 ms 856 KB Output is correct
61 Correct 51 ms 10064 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 0 ms 432 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 24 ms 6280 KB Output is correct
66 Correct 45 ms 10168 KB Output is correct
67 Correct 46 ms 10068 KB Output is correct
68 Correct 47 ms 10072 KB Output is correct
69 Correct 48 ms 14204 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 5 ms 1184 KB Output is correct
7 Correct 113 ms 24148 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 5 ms 1368 KB Output is correct
13 Correct 117 ms 24200 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 58 ms 10120 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 29 ms 6280 KB Output is correct
21 Correct 129 ms 24144 KB Output is correct
22 Correct 112 ms 24144 KB Output is correct
23 Correct 120 ms 23920 KB Output is correct
24 Correct 123 ms 23976 KB Output is correct
25 Correct 50 ms 10248 KB Output is correct
26 Correct 49 ms 10172 KB Output is correct
27 Correct 145 ms 24148 KB Output is correct
28 Correct 113 ms 24144 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 6 ms 1404 KB Output is correct
37 Correct 112 ms 24188 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 5 ms 1372 KB Output is correct
41 Correct 112 ms 24180 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 3 ms 604 KB Output is correct
45 Correct 54 ms 10096 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 39 ms 6268 KB Output is correct
50 Correct 113 ms 24148 KB Output is correct
51 Correct 118 ms 24180 KB Output is correct
52 Correct 117 ms 24148 KB Output is correct
53 Correct 50 ms 14172 KB Output is correct
54 Correct 48 ms 10228 KB Output is correct
55 Correct 113 ms 23980 KB Output is correct
56 Correct 137 ms 24180 KB Output is correct
57 Correct 52 ms 14196 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 35 ms 6224 KB Output is correct
62 Correct 113 ms 24072 KB Output is correct
63 Correct 123 ms 24072 KB Output is correct
64 Correct 121 ms 24108 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 28 ms 6440 KB Output is correct
67 Correct 113 ms 24148 KB Output is correct
68 Correct 104 ms 24144 KB Output is correct
69 Correct 107 ms 24140 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
73 Correct 29 ms 6420 KB Output is correct
74 Correct 108 ms 24140 KB Output is correct
75 Correct 103 ms 23944 KB Output is correct
76 Correct 111 ms 24144 KB Output is correct
77 Correct 114 ms 24148 KB Output is correct
78 Correct 0 ms 348 KB Output is correct
79 Correct 0 ms 348 KB Output is correct
80 Correct 2 ms 856 KB Output is correct
81 Correct 51 ms 10064 KB Output is correct
82 Correct 1 ms 344 KB Output is correct
83 Correct 0 ms 432 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 24 ms 6280 KB Output is correct
86 Correct 45 ms 10168 KB Output is correct
87 Correct 46 ms 10068 KB Output is correct
88 Correct 47 ms 10072 KB Output is correct
89 Correct 48 ms 14204 KB Output is correct
90 Correct 1 ms 344 KB Output is correct
91 Correct 1 ms 344 KB Output is correct
92 Correct 2 ms 676 KB Output is correct
93 Correct 45 ms 10068 KB Output is correct
94 Incorrect 1 ms 348 KB Answer gives possible 1 while actual possible 0
95 Halted 0 ms 0 KB -