Submission #847064

# Submission time Handle Problem Language Result Execution time Memory
847064 2023-09-09T05:38:38 Z siewjh Vision Program (IOI19_vision) C++17
100 / 100
23 ms 2936 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
int rows, cols, dlen, dist;
bool valid(int r, int c){
	return r >= 0 && c >= 0 && r < rows && c < cols;
}
int coord(int r, int c){
	return r * cols + c;
}
pair<int, int> solve(bool dir){
	vector<int> diag;
	if (dir){
		for (int i = 0; i < rows; i++){
			vector<int> test;
			int r = i, c = 0;
			for (; valid(r, c); r--, c++) test.push_back(coord(r, c));
			diag.push_back(add_or(test));
		}
		for (int i = 1; i < cols; i++){
			vector<int> test;
			int r = rows - 1, c = i;
			for (; valid(r, c); r--, c++) test.push_back(coord(r, c));
			diag.push_back(add_or(test));
		}
	}
	else{
		for (int i = 0; i < rows; i++){
			vector<int> test;
			int r = i, c = cols - 1;
			for (; valid(r, c); r--, c--) test.push_back(coord(r, c));
			diag.push_back(add_or(test));
		}
		for (int i = cols - 2; i >= 0; i--){
			vector<int> test;
			int r = rows - 1, c = i;
			for (; valid(r, c); r--, c--) test.push_back(coord(r, c));
			diag.push_back(add_or(test));
		}
	}
	int same = add_xor(diag), k, lk;
	vector<int> vk, vlk;
	for (int i = dlen - 1; i >= dist; i--) vk.push_back(add_and({diag[i - dist], diag[i]}));
	k = add_or(vk);
	for (int i = dlen - 1; i >= dist; i--){
		vector<int> test;
		for (int j = 0; j <= dist; j++) test.push_back(diag[i - j]);
		int present = add_or(test), one = add_xor(test);
		vlk.push_back(add_and({present, add_not(one)}));
	}
	vlk.push_back(same);
	lk = add_or(vlk);
	return {k, lk};
}
void construct_network(int H, int W, int K) {
	rows = H, cols = W, dlen = H + W - 1, dist = K;
	auto lp = solve(1), rp = solve(0);
	int a1 = add_and({lp.first, rp.second}), a2 = add_and({lp.second, rp.first});
	add_or({a1, a2});
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 436 KB Output is correct
13 Correct 0 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 0 ms 432 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 436 KB Output is correct
13 Correct 0 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 0 ms 432 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 436 KB Output is correct
13 Correct 0 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 0 ms 432 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 432 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 436 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 436 KB Output is correct
13 Correct 0 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 0 ms 432 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 432 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 436 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 5 ms 860 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 432 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 3 ms 860 KB Output is correct
44 Correct 5 ms 860 KB Output is correct
45 Correct 6 ms 860 KB Output is correct
46 Correct 6 ms 856 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 4 ms 860 KB Output is correct
7 Correct 4 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 4 ms 860 KB Output is correct
12 Correct 5 ms 856 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 4 ms 860 KB Output is correct
19 Correct 3 ms 856 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 3 ms 652 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 4 ms 728 KB Output is correct
10 Correct 4 ms 860 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 4 ms 664 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 4 ms 816 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 5 ms 1116 KB Output is correct
21 Correct 11 ms 1628 KB Output is correct
22 Correct 10 ms 1632 KB Output is correct
23 Correct 4 ms 856 KB Output is correct
24 Correct 5 ms 1116 KB Output is correct
25 Correct 12 ms 1892 KB Output is correct
26 Correct 4 ms 860 KB Output is correct
27 Correct 9 ms 1496 KB Output is correct
28 Correct 18 ms 2484 KB Output is correct
29 Correct 23 ms 2792 KB Output is correct
30 Correct 17 ms 2424 KB Output is correct
31 Correct 7 ms 1116 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1496 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 5 ms 1116 KB Output is correct
8 Correct 5 ms 1064 KB Output is correct
9 Correct 9 ms 1492 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 436 KB Output is correct
13 Correct 0 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 0 ms 432 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 432 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 436 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 5 ms 860 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 432 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 3 ms 860 KB Output is correct
44 Correct 5 ms 860 KB Output is correct
45 Correct 6 ms 860 KB Output is correct
46 Correct 6 ms 856 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 2 ms 604 KB Output is correct
49 Correct 4 ms 860 KB Output is correct
50 Correct 5 ms 860 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 4 ms 860 KB Output is correct
54 Correct 4 ms 604 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 1 ms 604 KB Output is correct
57 Correct 4 ms 604 KB Output is correct
58 Correct 4 ms 860 KB Output is correct
59 Correct 5 ms 856 KB Output is correct
60 Correct 3 ms 604 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 604 KB Output is correct
63 Correct 3 ms 604 KB Output is correct
64 Correct 4 ms 860 KB Output is correct
65 Correct 4 ms 860 KB Output is correct
66 Correct 3 ms 856 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 1 ms 348 KB Output is correct
70 Correct 0 ms 436 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 2 ms 600 KB Output is correct
73 Correct 2 ms 604 KB Output is correct
74 Correct 3 ms 652 KB Output is correct
75 Correct 2 ms 600 KB Output is correct
76 Correct 1 ms 344 KB Output is correct
77 Correct 2 ms 604 KB Output is correct
78 Correct 4 ms 728 KB Output is correct
79 Correct 4 ms 860 KB Output is correct
80 Correct 4 ms 604 KB Output is correct
81 Correct 2 ms 344 KB Output is correct
82 Correct 2 ms 604 KB Output is correct
83 Correct 4 ms 664 KB Output is correct
84 Correct 3 ms 604 KB Output is correct
85 Correct 1 ms 348 KB Output is correct
86 Correct 1 ms 604 KB Output is correct
87 Correct 4 ms 816 KB Output is correct
88 Correct 1 ms 348 KB Output is correct
89 Correct 5 ms 1116 KB Output is correct
90 Correct 11 ms 1628 KB Output is correct
91 Correct 10 ms 1632 KB Output is correct
92 Correct 4 ms 856 KB Output is correct
93 Correct 5 ms 1116 KB Output is correct
94 Correct 12 ms 1892 KB Output is correct
95 Correct 4 ms 860 KB Output is correct
96 Correct 9 ms 1496 KB Output is correct
97 Correct 18 ms 2484 KB Output is correct
98 Correct 23 ms 2792 KB Output is correct
99 Correct 17 ms 2424 KB Output is correct
100 Correct 7 ms 1116 KB Output is correct
101 Correct 0 ms 348 KB Output is correct
102 Correct 0 ms 348 KB Output is correct
103 Correct 9 ms 1496 KB Output is correct
104 Correct 0 ms 348 KB Output is correct
105 Correct 1 ms 604 KB Output is correct
106 Correct 2 ms 604 KB Output is correct
107 Correct 1 ms 436 KB Output is correct
108 Correct 1 ms 604 KB Output is correct
109 Correct 5 ms 1116 KB Output is correct
110 Correct 5 ms 1064 KB Output is correct
111 Correct 9 ms 1492 KB Output is correct
112 Correct 0 ms 348 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 18 ms 2652 KB Output is correct
115 Correct 1 ms 344 KB Output is correct
116 Correct 2 ms 604 KB Output is correct
117 Correct 8 ms 1360 KB Output is correct
118 Correct 9 ms 1372 KB Output is correct
119 Correct 21 ms 2908 KB Output is correct
120 Correct 21 ms 2936 KB Output is correct
121 Correct 21 ms 2908 KB Output is correct
122 Correct 21 ms 2908 KB Output is correct
123 Correct 9 ms 1492 KB Output is correct
124 Correct 18 ms 2652 KB Output is correct
125 Correct 20 ms 2896 KB Output is correct
126 Correct 21 ms 2896 KB Output is correct
127 Correct 17 ms 2396 KB Output is correct
128 Correct 7 ms 1116 KB Output is correct