답안 #610852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
610852 2022-07-28T16:10:31 Z fvogel499 Vision Program (IOI19_vision) C++17
100 / 100
62 ms 7620 KB
#include "vision.h"
#include <bits/stdc++.h>

#define vi vector<int>

using namespace std;

// #define size(x) (int)((x).size())

// vi b = {1, 0, 0, 0, 0, 1};

// int add_or(vi elems) {
// 	assert(!elems.empty());
// 	b.push_back(0);
// 	for (int i : elems) {
// 		b.back() |= b[i];
// 	}
// 	cout << "after OR operation: " << b.back() << endl;
// 	return size(b)-1;
// }

// int add_and(vi elems) {
// 	assert(!elems.empty());
// 	b.push_back(1);
// 	for (int i : elems) {
// 		b.back() &= b[i];
// 	}
// 	cout << "after AND operation: " << b.back() << endl;
// 	return size(b)-1;
// }

// int add_xor(vi elems) {
// 	assert(!elems.empty());
// 	b.push_back(0);
// 	for (int i : elems) {
// 		b.back() ^= b[i];
// 	}
// 	cout << "after XOR operation: " << b.back() << endl;
// 	return size(b)-1;
// }

// int add_not(int x) {
// 	b.push_back(!b[x]);
// 	cout << "after NOT operation: " << b.back() << endl;
// 	return size(b)-1;
// }

int check_k(int h, int w, int kConst) {
	vi on [2][h+w-1];
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
		int leftDiag = j - i + h - 1;
		assert(0 <= leftDiag && leftDiag < h+w-1);
		int rightDiag = i+j;
		assert(0 <= rightDiag && rightDiag < h+w-1);
		on[0][leftDiag].push_back(i*w+j);
		on[1][rightDiag].push_back(i*w+j);
	}
	int posOr [2][h+w-1];
	int posXor [2][h+w-1];
	int posNotXor [2][h+w-1];
	int posTwoContained [2][h+w-1];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < h+w-1; j++) {
			posOr[i][j] = add_or(on[i][j]);
			posXor[i][j] = add_xor(on[i][j]);
			posNotXor[i][j] = add_not(posXor[i][j]);
			posTwoContained[i][j] = add_and({posOr[i][j], posNotXor[i][j]});
		}
	}
	int finalAnswer [2];
	for (int i = 0; i < 2; i++) {
		vi toOr;
		for (int j = 0; j < h+w-1; j++) {
			toOr.push_back(posTwoContained[i][j]);
		}
		for (int j = 0; j < h+w-1 -1; j++) {
			vi consecutive;
			for (int k = j+1; k < min(h+w-1, j+1+kConst); k++) {
				consecutive.push_back(posOr[i][k]);
			}
			int orAllConsecutive = add_or(consecutive);
			toOr.push_back(add_and({posOr[i][j], orAllConsecutive}));
		}
		finalAnswer[i] = add_or(toOr);
	}
	int ansAt = add_and({finalAnswer[0], finalAnswer[1]});
	return ansAt;
}

void construct_network(int h, int w, int k) {
	int kAt = check_k(h, w, k);
	if (k >= 2) {
		int smKAt = check_k(h, w, k - 1);
		int notSmKAt = add_not(smKAt);
		add_and({kAt, notSmKAt});
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 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 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 300 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 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 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 300 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 296 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 424 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 424 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 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 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 300 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 296 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 424 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 424 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
38 Correct 14 ms 1744 KB Output is correct
39 Correct 2 ms 556 KB Output is correct
40 Correct 3 ms 548 KB Output is correct
41 Correct 6 ms 980 KB Output is correct
42 Correct 9 ms 1364 KB Output is correct
43 Correct 5 ms 980 KB Output is correct
44 Correct 14 ms 1824 KB Output is correct
45 Correct 15 ms 1992 KB Output is correct
46 Correct 17 ms 2128 KB Output is correct
47 Correct 17 ms 2248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 7 ms 1104 KB Output is correct
3 Correct 8 ms 1196 KB Output is correct
4 Correct 10 ms 1360 KB Output is correct
5 Correct 3 ms 724 KB Output is correct
6 Correct 6 ms 1056 KB Output is correct
7 Correct 9 ms 1228 KB Output is correct
8 Correct 9 ms 1276 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 6 ms 1000 KB Output is correct
11 Correct 11 ms 1204 KB Output is correct
12 Correct 10 ms 1104 KB Output is correct
13 Correct 9 ms 1316 KB Output is correct
14 Correct 9 ms 1360 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 6 ms 976 KB Output is correct
17 Correct 8 ms 1104 KB Output is correct
18 Correct 10 ms 1128 KB Output is correct
19 Correct 9 ms 1232 KB Output is correct
20 Correct 10 ms 1360 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 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 2 ms 468 KB Output is correct
4 Correct 5 ms 852 KB Output is correct
5 Correct 7 ms 852 KB Output is correct
6 Correct 7 ms 980 KB Output is correct
7 Correct 7 ms 980 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 9 ms 1276 KB Output is correct
10 Correct 11 ms 1480 KB Output is correct
11 Correct 11 ms 1572 KB Output is correct
12 Correct 12 ms 1616 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 6 ms 976 KB Output is correct
15 Correct 9 ms 1232 KB Output is correct
16 Correct 10 ms 1332 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 8 ms 1156 KB Output is correct
19 Correct 9 ms 1360 KB Output is correct
20 Correct 9 ms 1556 KB Output is correct
21 Correct 27 ms 3536 KB Output is correct
22 Correct 32 ms 4016 KB Output is correct
23 Correct 36 ms 4324 KB Output is correct
24 Correct 10 ms 1492 KB Output is correct
25 Correct 32 ms 3864 KB Output is correct
26 Correct 34 ms 4224 KB Output is correct
27 Correct 17 ms 2640 KB Output is correct
28 Correct 49 ms 5820 KB Output is correct
29 Correct 54 ms 6852 KB Output is correct
30 Correct 59 ms 7484 KB Output is correct
31 Correct 62 ms 7608 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 2600 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 9 ms 1492 KB Output is correct
8 Correct 9 ms 1492 KB Output is correct
9 Correct 23 ms 2612 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 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 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 300 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 296 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 424 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 424 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
38 Correct 14 ms 1744 KB Output is correct
39 Correct 2 ms 556 KB Output is correct
40 Correct 3 ms 548 KB Output is correct
41 Correct 6 ms 980 KB Output is correct
42 Correct 9 ms 1364 KB Output is correct
43 Correct 5 ms 980 KB Output is correct
44 Correct 14 ms 1824 KB Output is correct
45 Correct 15 ms 1992 KB Output is correct
46 Correct 17 ms 2128 KB Output is correct
47 Correct 17 ms 2248 KB Output is correct
48 Correct 2 ms 468 KB Output is correct
49 Correct 7 ms 1104 KB Output is correct
50 Correct 8 ms 1196 KB Output is correct
51 Correct 10 ms 1360 KB Output is correct
52 Correct 3 ms 724 KB Output is correct
53 Correct 6 ms 1056 KB Output is correct
54 Correct 9 ms 1228 KB Output is correct
55 Correct 9 ms 1276 KB Output is correct
56 Correct 2 ms 468 KB Output is correct
57 Correct 6 ms 1000 KB Output is correct
58 Correct 11 ms 1204 KB Output is correct
59 Correct 10 ms 1104 KB Output is correct
60 Correct 9 ms 1316 KB Output is correct
61 Correct 9 ms 1360 KB Output is correct
62 Correct 2 ms 468 KB Output is correct
63 Correct 6 ms 976 KB Output is correct
64 Correct 8 ms 1104 KB Output is correct
65 Correct 10 ms 1128 KB Output is correct
66 Correct 9 ms 1232 KB Output is correct
67 Correct 10 ms 1360 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 2 ms 468 KB Output is correct
73 Correct 5 ms 852 KB Output is correct
74 Correct 7 ms 852 KB Output is correct
75 Correct 7 ms 980 KB Output is correct
76 Correct 7 ms 980 KB Output is correct
77 Correct 3 ms 724 KB Output is correct
78 Correct 9 ms 1276 KB Output is correct
79 Correct 11 ms 1480 KB Output is correct
80 Correct 11 ms 1572 KB Output is correct
81 Correct 12 ms 1616 KB Output is correct
82 Correct 1 ms 468 KB Output is correct
83 Correct 6 ms 976 KB Output is correct
84 Correct 9 ms 1232 KB Output is correct
85 Correct 10 ms 1332 KB Output is correct
86 Correct 1 ms 468 KB Output is correct
87 Correct 8 ms 1156 KB Output is correct
88 Correct 9 ms 1360 KB Output is correct
89 Correct 9 ms 1556 KB Output is correct
90 Correct 27 ms 3536 KB Output is correct
91 Correct 32 ms 4016 KB Output is correct
92 Correct 36 ms 4324 KB Output is correct
93 Correct 10 ms 1492 KB Output is correct
94 Correct 32 ms 3864 KB Output is correct
95 Correct 34 ms 4224 KB Output is correct
96 Correct 17 ms 2640 KB Output is correct
97 Correct 49 ms 5820 KB Output is correct
98 Correct 54 ms 6852 KB Output is correct
99 Correct 59 ms 7484 KB Output is correct
100 Correct 62 ms 7608 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 1 ms 300 KB Output is correct
103 Correct 17 ms 2600 KB Output is correct
104 Correct 1 ms 256 KB Output is correct
105 Correct 2 ms 468 KB Output is correct
106 Correct 4 ms 724 KB Output is correct
107 Correct 2 ms 468 KB Output is correct
108 Correct 2 ms 468 KB Output is correct
109 Correct 9 ms 1492 KB Output is correct
110 Correct 9 ms 1492 KB Output is correct
111 Correct 23 ms 2612 KB Output is correct
112 Correct 0 ms 212 KB Output is correct
113 Correct 0 ms 212 KB Output is correct
114 Correct 47 ms 5824 KB Output is correct
115 Correct 9 ms 1360 KB Output is correct
116 Correct 3 ms 724 KB Output is correct
117 Correct 33 ms 4268 KB Output is correct
118 Correct 23 ms 3004 KB Output is correct
119 Correct 55 ms 6844 KB Output is correct
120 Correct 54 ms 6852 KB Output is correct
121 Correct 55 ms 6912 KB Output is correct
122 Correct 57 ms 6812 KB Output is correct
123 Correct 18 ms 2692 KB Output is correct
124 Correct 48 ms 5840 KB Output is correct
125 Correct 53 ms 6880 KB Output is correct
126 Correct 58 ms 7024 KB Output is correct
127 Correct 61 ms 7532 KB Output is correct
128 Correct 61 ms 7620 KB Output is correct