답안 #586025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586025 2022-06-29T18:18:20 Z serize 슈퍼트리 잇기 (IOI20_supertrees) C++17
40 / 100
233 ms 26496 KB
#include "supertrees.h"
#include<bits/stdc++.h>
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;

const int MAX = 1002;

int link[MAX];

inline int seek(int x){
    if(x == link[x]) return x;
    return link[x] = seek(link[x]);
}

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	std::vector<std::vector<int>> answer;
	for(int i = 0; i < n; i++) link[i] = i;
	int f = 0;
	bool flag = 1;
	for(auto i: p){
        int a = seek(f);
        for(int j = 0; j < n; j++){
            if(f!=j and i[j] == 1) flag = 0;
            if(i[j] != 0){
                int b = seek(j);
                link[b] = a;
            }
        }
        f++;
	}
	vector<int> cc[MAX];
	for(int i = 0; i < n; i++){
        cc[ link[i]  ].push_back(i);
	}
	int mat[n+1][n+1];
	memset(mat,0,sizeof(mat));
	bool good = 1;
	for(int i = 0; i < n; i++){
        int sz = (int)(cc[i].size());
        for(int j = 0; j < sz-1; j++){
            mat[ cc[i][j] ][ cc[i][j+1]  ] = 1;
            mat[ cc[i][j+1] ][ cc[i][j]  ] = 1;
        }
        if(flag and sz == 2){
            good = 0;
        }
        if(flag and sz > 2){
            mat[ cc[i][0]  ][  cc[i][ sz-1 ] ] = 1;
            mat[ cc[i][ sz-1 ]  ][ cc[i][0]  ] = 1;
        }
	}
 	for(int i = 0; i < n; i++){
        vector<int> asd;
        for(int j = 0; j < n; j++){
            asd.push_back(mat[i][j]);
        }
        answer.push_back(asd);
	}
    bool ok = 1;
    f = 0;
    for(auto i: p){
        for(int j = 0; j < n; j++){
             if(i[j] == 0 and link[f] == link[j]){
                ok = 0;
                break;
             }
        }
        f++;
        if(!ok) break;
	}
	if(ok and good){
        build(answer);
        return 1;
	}
	else return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 304 KB Output is correct
6 Correct 8 ms 1392 KB Output is correct
7 Correct 175 ms 26452 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 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 8 ms 1392 KB Output is correct
7 Correct 175 ms 26452 KB Output is correct
8 Correct 1 ms 212 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 304 KB Output is correct
12 Correct 10 ms 1416 KB Output is correct
13 Correct 173 ms 26412 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 980 KB Output is correct
17 Correct 84 ms 16388 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 45 ms 7060 KB Output is correct
21 Correct 233 ms 26288 KB Output is correct
22 Correct 181 ms 26404 KB Output is correct
23 Correct 189 ms 26396 KB Output is correct
24 Correct 180 ms 26376 KB Output is correct
25 Correct 72 ms 16472 KB Output is correct
26 Correct 69 ms 16420 KB Output is correct
27 Correct 207 ms 26308 KB Output is correct
28 Correct 172 ms 26496 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 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 8 ms 1432 KB Output is correct
9 Correct 168 ms 26312 KB Output is correct
10 Correct 1 ms 260 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1336 KB Output is correct
13 Correct 227 ms 26348 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 980 KB Output is correct
17 Correct 82 ms 16364 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 45 ms 6936 KB Output is correct
22 Correct 172 ms 26364 KB Output is correct
23 Correct 178 ms 26284 KB Output is correct
24 Correct 184 ms 26348 KB Output is correct
25 Correct 89 ms 16388 KB Output is correct
26 Correct 72 ms 16456 KB Output is correct
27 Correct 199 ms 26412 KB Output is correct
28 Correct 204 ms 26372 KB Output is correct
29 Correct 72 ms 16480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 47 ms 6956 KB Output is correct
5 Correct 199 ms 26316 KB Output is correct
6 Correct 170 ms 26380 KB Output is correct
7 Correct 208 ms 26400 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 44 ms 7036 KB Output is correct
10 Correct 170 ms 26360 KB Output is correct
11 Correct 173 ms 26392 KB Output is correct
12 Correct 191 ms 26376 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Incorrect 0 ms 304 KB Too few ways to get from 0 to 1, should be 2 found 1
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 304 KB Output is correct
6 Correct 8 ms 1392 KB Output is correct
7 Correct 175 ms 26452 KB Output is correct
8 Correct 1 ms 212 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 304 KB Output is correct
12 Correct 10 ms 1416 KB Output is correct
13 Correct 173 ms 26412 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 980 KB Output is correct
17 Correct 84 ms 16388 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 45 ms 7060 KB Output is correct
21 Correct 233 ms 26288 KB Output is correct
22 Correct 181 ms 26404 KB Output is correct
23 Correct 189 ms 26396 KB Output is correct
24 Correct 180 ms 26376 KB Output is correct
25 Correct 72 ms 16472 KB Output is correct
26 Correct 69 ms 16420 KB Output is correct
27 Correct 207 ms 26308 KB Output is correct
28 Correct 172 ms 26496 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 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 8 ms 1432 KB Output is correct
37 Correct 168 ms 26312 KB Output is correct
38 Correct 1 ms 260 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 7 ms 1336 KB Output is correct
41 Correct 227 ms 26348 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 4 ms 980 KB Output is correct
45 Correct 82 ms 16364 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 300 KB Output is correct
49 Correct 45 ms 6936 KB Output is correct
50 Correct 172 ms 26364 KB Output is correct
51 Correct 178 ms 26284 KB Output is correct
52 Correct 184 ms 26348 KB Output is correct
53 Correct 89 ms 16388 KB Output is correct
54 Correct 72 ms 16456 KB Output is correct
55 Correct 199 ms 26412 KB Output is correct
56 Correct 204 ms 26372 KB Output is correct
57 Correct 72 ms 16480 KB Output is correct
58 Correct 1 ms 308 KB Output is correct
59 Correct 1 ms 300 KB Output is correct
60 Correct 4 ms 980 KB Output is correct
61 Correct 82 ms 16444 KB Output is correct
62 Correct 0 ms 212 KB Output is correct
63 Incorrect 1 ms 212 KB Too few ways to get from 3 to 4, should be 2 found 1
64 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 304 KB Output is correct
6 Correct 8 ms 1392 KB Output is correct
7 Correct 175 ms 26452 KB Output is correct
8 Correct 1 ms 212 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 304 KB Output is correct
12 Correct 10 ms 1416 KB Output is correct
13 Correct 173 ms 26412 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 980 KB Output is correct
17 Correct 84 ms 16388 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 45 ms 7060 KB Output is correct
21 Correct 233 ms 26288 KB Output is correct
22 Correct 181 ms 26404 KB Output is correct
23 Correct 189 ms 26396 KB Output is correct
24 Correct 180 ms 26376 KB Output is correct
25 Correct 72 ms 16472 KB Output is correct
26 Correct 69 ms 16420 KB Output is correct
27 Correct 207 ms 26308 KB Output is correct
28 Correct 172 ms 26496 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 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 8 ms 1432 KB Output is correct
37 Correct 168 ms 26312 KB Output is correct
38 Correct 1 ms 260 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 7 ms 1336 KB Output is correct
41 Correct 227 ms 26348 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 4 ms 980 KB Output is correct
45 Correct 82 ms 16364 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 300 KB Output is correct
49 Correct 45 ms 6936 KB Output is correct
50 Correct 172 ms 26364 KB Output is correct
51 Correct 178 ms 26284 KB Output is correct
52 Correct 184 ms 26348 KB Output is correct
53 Correct 89 ms 16388 KB Output is correct
54 Correct 72 ms 16456 KB Output is correct
55 Correct 199 ms 26412 KB Output is correct
56 Correct 204 ms 26372 KB Output is correct
57 Correct 72 ms 16480 KB Output is correct
58 Correct 1 ms 304 KB Output is correct
59 Correct 1 ms 300 KB Output is correct
60 Correct 0 ms 304 KB Output is correct
61 Correct 47 ms 6956 KB Output is correct
62 Correct 199 ms 26316 KB Output is correct
63 Correct 170 ms 26380 KB Output is correct
64 Correct 208 ms 26400 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 44 ms 7036 KB Output is correct
67 Correct 170 ms 26360 KB Output is correct
68 Correct 173 ms 26392 KB Output is correct
69 Correct 191 ms 26376 KB Output is correct
70 Correct 1 ms 300 KB Output is correct
71 Incorrect 0 ms 304 KB Too few ways to get from 0 to 1, should be 2 found 1
72 Halted 0 ms 0 KB -