답안 #439196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439196 2021-06-29T11:26:31 Z dutch Vision Program (IOI19_vision) C++17
100 / 100
18 ms 1440 KB
#include <bits/stdc++.h>
using namespace std;
#include "vision.h"
#define G(i, j) (rotated ? j*h + i : i*w + j)
#define V(i, j) vector<int> {i, j}

const int N = 200, BIT = 8;
int a[N], b[2][N], p, pTrue, pFalse;
bool rotated = 0;

vector<int> sum(vector<int> &x, vector<int> &y){
	vector<int> res(BIT);
	int extra = pFalse;
	for(int c=0; c<BIT; ++c){
		add_xor(vector<int> {x[c], y[c], extra}); res[c] = p++;

		add_and(V(x[c], extra)); int a1 = p++;
		add_and(V(y[c], extra)); int a2 = p++;
		add_and(V(x[c], y[c])); int a3 = p++;
		add_or(vector<int> {a1, a2, a3}); extra = p++;
	}

	return res;
}

void construct_network(int h, int w, int k){
	if((p = h*w) < 3) return void(add_and(V(0, 1)));
	add_and(vector<int> {0, 1, 2}); pFalse = p++;
	add_not(pFalse); pTrue = p++;
	vector<int> one(BIT, pFalse); one[0] = pTrue;

	vector<int> res[2];

	for(int _=0; _<2; ++_){
		rotated = !rotated;
		swap(h, w);
		for(int i=0; i<h; ++i){
			vector<int> q(w);
			for(int j=0; j<w; ++j) q[j] = G(i, j);
			add_or(q); a[i] = p++;
		}

		b[0][0] = b[1][h-1] = pTrue;

		for(int i=1; i<h; ++i)
			add_xor(V(b[0][i-1], a[i-1])), b[0][i] = p++;
		for(int i=h-2; i>=0; --i)
			add_xor(V(b[1][i+1], a[i+1])), b[1][i] = p++;

		vector<vector<int>> num(2, vector<int> (BIT));
		for(int c=0; c<BIT; ++c){
			vector<int> curr[2];
			for(int i=0; i<h; ++i) if(i & (1<<c))
				for(int j=0; j<2; ++j)
					add_and(V(a[i], b[j][i])), curr[j].push_back(p++);
			for(int j=0; j<2; ++j){
				if(curr[j].empty()) num[j][c] = pFalse;
				else add_or(curr[j]), num[j][c] = p++;
			}
			add_not(num[0][c]); num[0][c] = p++;
		}
		res[_] = sum(num[0], num[1]);
		// res[_] = sum(res[_], one);
	}
	vector<int> ans = sum(res[0], res[1]);
	vector<int> two(BIT, pFalse); two[1] = pTrue;
	ans = sum(ans, two);
	vector<int> bits[2];
	for(int c=0; c<BIT; ++c)
		bits[bool((1<<c) & k)].push_back(ans[c]);
	add_and(bits[1]); int on = p++;
	add_or(bits[0]);
	add_not(p++);
	add_and(V(on, p++));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 300 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 1 ms 296 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 300 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 1 ms 296 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 4 ms 716 KB Output is correct
39 Correct 2 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 3 ms 460 KB Output is correct
42 Correct 3 ms 460 KB Output is correct
43 Correct 4 ms 716 KB Output is correct
44 Correct 6 ms 716 KB Output is correct
45 Correct 5 ms 716 KB Output is correct
46 Correct 4 ms 680 KB Output is correct
47 Correct 4 ms 704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 2 ms 460 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 3 ms 460 KB Output is correct
20 Correct 3 ms 460 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
8 Correct 4 ms 552 KB Output is correct
9 Correct 4 ms 460 KB Output is correct
10 Correct 4 ms 588 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Correct 4 ms 520 KB Output is correct
13 Correct 2 ms 460 KB Output is correct
14 Correct 2 ms 552 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 2 ms 528 KB Output is correct
20 Correct 7 ms 936 KB Output is correct
21 Correct 7 ms 972 KB Output is correct
22 Correct 7 ms 936 KB Output is correct
23 Correct 7 ms 972 KB Output is correct
24 Correct 7 ms 844 KB Output is correct
25 Correct 9 ms 936 KB Output is correct
26 Correct 10 ms 844 KB Output is correct
27 Correct 13 ms 1360 KB Output is correct
28 Correct 13 ms 1336 KB Output is correct
29 Correct 13 ms 1352 KB Output is correct
30 Correct 13 ms 1352 KB Output is correct
31 Correct 13 ms 1440 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1420 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 7 ms 972 KB Output is correct
8 Correct 7 ms 844 KB Output is correct
9 Correct 13 ms 1352 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 300 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 1 ms 296 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 4 ms 716 KB Output is correct
39 Correct 2 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 3 ms 460 KB Output is correct
42 Correct 3 ms 460 KB Output is correct
43 Correct 4 ms 716 KB Output is correct
44 Correct 6 ms 716 KB Output is correct
45 Correct 5 ms 716 KB Output is correct
46 Correct 4 ms 680 KB Output is correct
47 Correct 4 ms 704 KB Output is correct
48 Correct 2 ms 460 KB Output is correct
49 Correct 2 ms 460 KB Output is correct
50 Correct 2 ms 460 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 2 ms 460 KB Output is correct
53 Correct 2 ms 460 KB Output is correct
54 Correct 3 ms 460 KB Output is correct
55 Correct 2 ms 460 KB Output is correct
56 Correct 2 ms 460 KB Output is correct
57 Correct 2 ms 460 KB Output is correct
58 Correct 2 ms 460 KB Output is correct
59 Correct 2 ms 460 KB Output is correct
60 Correct 2 ms 460 KB Output is correct
61 Correct 2 ms 460 KB Output is correct
62 Correct 2 ms 460 KB Output is correct
63 Correct 2 ms 460 KB Output is correct
64 Correct 2 ms 460 KB Output is correct
65 Correct 2 ms 460 KB Output is correct
66 Correct 3 ms 460 KB Output is correct
67 Correct 3 ms 460 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 1 ms 332 KB Output is correct
72 Correct 2 ms 460 KB Output is correct
73 Correct 2 ms 460 KB Output is correct
74 Correct 2 ms 460 KB Output is correct
75 Correct 2 ms 460 KB Output is correct
76 Correct 3 ms 460 KB Output is correct
77 Correct 4 ms 552 KB Output is correct
78 Correct 4 ms 460 KB Output is correct
79 Correct 4 ms 588 KB Output is correct
80 Correct 4 ms 460 KB Output is correct
81 Correct 4 ms 520 KB Output is correct
82 Correct 2 ms 460 KB Output is correct
83 Correct 2 ms 552 KB Output is correct
84 Correct 2 ms 460 KB Output is correct
85 Correct 3 ms 460 KB Output is correct
86 Correct 2 ms 460 KB Output is correct
87 Correct 2 ms 460 KB Output is correct
88 Correct 2 ms 528 KB Output is correct
89 Correct 7 ms 936 KB Output is correct
90 Correct 7 ms 972 KB Output is correct
91 Correct 7 ms 936 KB Output is correct
92 Correct 7 ms 972 KB Output is correct
93 Correct 7 ms 844 KB Output is correct
94 Correct 9 ms 936 KB Output is correct
95 Correct 10 ms 844 KB Output is correct
96 Correct 13 ms 1360 KB Output is correct
97 Correct 13 ms 1336 KB Output is correct
98 Correct 13 ms 1352 KB Output is correct
99 Correct 13 ms 1352 KB Output is correct
100 Correct 13 ms 1440 KB Output is correct
101 Correct 1 ms 204 KB Output is correct
102 Correct 1 ms 204 KB Output is correct
103 Correct 12 ms 1420 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 2 ms 460 KB Output is correct
106 Correct 3 ms 460 KB Output is correct
107 Correct 2 ms 460 KB Output is correct
108 Correct 2 ms 460 KB Output is correct
109 Correct 7 ms 972 KB Output is correct
110 Correct 7 ms 844 KB Output is correct
111 Correct 13 ms 1352 KB Output is correct
112 Correct 1 ms 296 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 13 ms 1420 KB Output is correct
115 Correct 2 ms 460 KB Output is correct
116 Correct 2 ms 460 KB Output is correct
117 Correct 7 ms 972 KB Output is correct
118 Correct 7 ms 932 KB Output is correct
119 Correct 13 ms 1396 KB Output is correct
120 Correct 18 ms 1328 KB Output is correct
121 Correct 13 ms 1352 KB Output is correct
122 Correct 13 ms 1352 KB Output is correct
123 Correct 14 ms 1440 KB Output is correct
124 Correct 13 ms 1352 KB Output is correct
125 Correct 12 ms 1352 KB Output is correct
126 Correct 13 ms 1432 KB Output is correct
127 Correct 12 ms 1352 KB Output is correct
128 Correct 12 ms 1352 KB Output is correct