Submission #425986

# Submission time Handle Problem Language Result Execution time Memory
425986 2021-06-13T12:44:59 Z Mazaalai Vision Program (IOI19_vision) C++17
100 / 100
79 ms 7540 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
 
/*
int add_not(int N)
int add_and(int[] Ns)
int add_or(int[] Ns)
int add_xor(int[] Ns)
*/
int n, m, K;
const int N = 1005;
int st1, end1, st2, end2;
vector <vector <int> > diag1(N), diag2(N);
vector <int> diag1_or(N), diag2_or(N);
vector <int> diag1_xor(N), diag2_xor(N);
vector <int> diag1_duo(N), diag2_duo(N);
int Idx(int A, int B) {
	// nums[A][B] = (A-1)*W + B;
	return A * m + B;
}
int Dist(int a, int b, int a1, int b1) {
	return abs(a-a1)+abs(b-b1);
}
int solve(int k) {
	vector <int> pos1;
	for (int i = st1; i + k - 1 <= end1; i++) {
		vector <int> vals, vals_duo;
		for (int j = i; j <= i + k - 1; j++) {
			vals.push_back(diag1_or[j]);
			vals_duo.push_back(diag1_duo[j]);
		}
		int a, b, c, d;
		a = vals.size() > 1 ? add_or(vals) : vals[0];
		b = vals.size() > 1 ? add_xor(vals) : vals[0];
		d = vals_duo.size() > 1 ? add_or(vals_duo) : vals_duo[0];
		c = add_xor({a, b});
		pos1.push_back(add_or({c, d}));
	}
	int ans1 = pos1.size() == 1 ? pos1[0] : add_or(pos1);
	vector <int> pos2;
	for (int i = st2; i + k - 1 <= end2; i++) {
		vector <int> vals, vals_duo;
		for (int j = i; j <= i + k - 1; j++) {
			vals.push_back(diag2_or[j]);
			vals_duo.push_back(diag2_duo[j]);
		}
		int a, b, c, d;
		a = vals.size() > 1 ? add_or(vals) : vals[0];
		b = vals.size() > 1 ? add_xor(vals) : vals[0];
		d = vals_duo.size() > 1 ? add_or(vals_duo) : vals_duo[0];
		c = add_xor({a, b});
		pos2.push_back(add_or({c, d}));
	}
	int ans2 = pos2.size() == 1 ? pos2[0] : add_or(pos2);
	return add_and({ans1, ans2});
}
void construct_network(int H, int W, int K1) {
	n = H, m = W, K = K1;
	st1 = N, end1 = 0, st2 = N, end2 = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int pos1 = i+j, pos2 = i-j+m, idx = Idx(i, j);
			diag1[pos1].push_back(idx);
			diag2[pos2].push_back(idx);
			st1=min(st1, pos1);
			end1=max(end1, pos1);
			st2=min(st2, pos2);
			end2=max(end2, pos2);
		}
	}
	for (int i = 0; i < N; i++) {
		if (diag1[i].size() >= 1) {
			diag1_or[i] = diag1[i].size() == 1 ? diag1[i][0] : add_or(diag1[i]);
			diag1_xor[i] = diag1[i].size() == 1 ? diag1[i][0] : add_xor(diag1[i]);
			diag1_duo[i] = add_xor({diag1_or[i], diag1_xor[i]});
		} 
		if (diag2[i].size() >= 1) {
			diag2_or[i] = diag2[i].size() == 1 ? diag2[i][0] : add_or(diag2[i]);
			diag2_xor[i] = diag2[i].size() == 1 ? diag2[i][0] : add_xor(diag2[i]);
			diag2_duo[i] = add_xor({diag2_or[i], diag2_xor[i]});
		} 
	}
	int x = solve(K+1), y = solve(K);
	add_xor({x, y});
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 276 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 380 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 276 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 380 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 3 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 2 ms 460 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 276 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 380 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 3 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 2 ms 460 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 18 ms 1976 KB Output is correct
39 Correct 4 ms 588 KB Output is correct
40 Correct 3 ms 460 KB Output is correct
41 Correct 5 ms 844 KB Output is correct
42 Correct 4 ms 588 KB Output is correct
43 Correct 8 ms 1100 KB Output is correct
44 Correct 17 ms 1984 KB Output is correct
45 Correct 20 ms 2168 KB Output is correct
46 Correct 18 ms 1868 KB Output is correct
47 Correct 6 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 16 ms 1356 KB Output is correct
3 Correct 15 ms 1356 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 4 ms 716 KB Output is correct
6 Correct 14 ms 1320 KB Output is correct
7 Correct 13 ms 1276 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 12 ms 1228 KB Output is correct
11 Correct 15 ms 1356 KB Output is correct
12 Correct 15 ms 1396 KB Output is correct
13 Correct 11 ms 1100 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 3 ms 588 KB Output is correct
16 Correct 13 ms 1228 KB Output is correct
17 Correct 19 ms 1416 KB Output is correct
18 Correct 15 ms 1356 KB Output is correct
19 Correct 11 ms 1072 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 716 KB Output is correct
4 Correct 8 ms 972 KB Output is correct
5 Correct 9 ms 1116 KB Output is correct
6 Correct 7 ms 844 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
8 Correct 6 ms 848 KB Output is correct
9 Correct 13 ms 1484 KB Output is correct
10 Correct 15 ms 1612 KB Output is correct
11 Correct 12 ms 1356 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 3 ms 588 KB Output is correct
14 Correct 13 ms 1356 KB Output is correct
15 Correct 12 ms 1144 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 3 ms 588 KB Output is correct
18 Correct 15 ms 1368 KB Output is correct
19 Correct 2 ms 408 KB Output is correct
20 Correct 13 ms 1736 KB Output is correct
21 Correct 40 ms 4080 KB Output is correct
22 Correct 39 ms 3884 KB Output is correct
23 Correct 11 ms 1484 KB Output is correct
24 Correct 13 ms 1736 KB Output is correct
25 Correct 42 ms 4272 KB Output is correct
26 Correct 11 ms 1460 KB Output is correct
27 Correct 24 ms 2912 KB Output is correct
28 Correct 63 ms 6508 KB Output is correct
29 Correct 77 ms 7480 KB Output is correct
30 Correct 60 ms 6216 KB Output is correct
31 Correct 21 ms 2636 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2940 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 4 ms 680 KB Output is correct
4 Correct 6 ms 884 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 4 ms 588 KB Output is correct
7 Correct 14 ms 1736 KB Output is correct
8 Correct 14 ms 1800 KB Output is correct
9 Correct 26 ms 3016 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 276 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 380 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 3 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 2 ms 460 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 18 ms 1976 KB Output is correct
39 Correct 4 ms 588 KB Output is correct
40 Correct 3 ms 460 KB Output is correct
41 Correct 5 ms 844 KB Output is correct
42 Correct 4 ms 588 KB Output is correct
43 Correct 8 ms 1100 KB Output is correct
44 Correct 17 ms 1984 KB Output is correct
45 Correct 20 ms 2168 KB Output is correct
46 Correct 18 ms 1868 KB Output is correct
47 Correct 6 ms 844 KB Output is correct
48 Correct 3 ms 588 KB Output is correct
49 Correct 16 ms 1356 KB Output is correct
50 Correct 15 ms 1356 KB Output is correct
51 Correct 2 ms 332 KB Output is correct
52 Correct 4 ms 716 KB Output is correct
53 Correct 14 ms 1320 KB Output is correct
54 Correct 13 ms 1276 KB Output is correct
55 Correct 2 ms 460 KB Output is correct
56 Correct 3 ms 588 KB Output is correct
57 Correct 12 ms 1228 KB Output is correct
58 Correct 15 ms 1356 KB Output is correct
59 Correct 15 ms 1396 KB Output is correct
60 Correct 11 ms 1100 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 3 ms 588 KB Output is correct
63 Correct 13 ms 1228 KB Output is correct
64 Correct 19 ms 1416 KB Output is correct
65 Correct 15 ms 1356 KB Output is correct
66 Correct 11 ms 1072 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 1 ms 332 KB Output is correct
72 Correct 3 ms 716 KB Output is correct
73 Correct 8 ms 972 KB Output is correct
74 Correct 9 ms 1116 KB Output is correct
75 Correct 7 ms 844 KB Output is correct
76 Correct 3 ms 460 KB Output is correct
77 Correct 6 ms 848 KB Output is correct
78 Correct 13 ms 1484 KB Output is correct
79 Correct 15 ms 1612 KB Output is correct
80 Correct 12 ms 1356 KB Output is correct
81 Correct 4 ms 716 KB Output is correct
82 Correct 3 ms 588 KB Output is correct
83 Correct 13 ms 1356 KB Output is correct
84 Correct 12 ms 1144 KB Output is correct
85 Correct 1 ms 332 KB Output is correct
86 Correct 3 ms 588 KB Output is correct
87 Correct 15 ms 1368 KB Output is correct
88 Correct 2 ms 408 KB Output is correct
89 Correct 13 ms 1736 KB Output is correct
90 Correct 40 ms 4080 KB Output is correct
91 Correct 39 ms 3884 KB Output is correct
92 Correct 11 ms 1484 KB Output is correct
93 Correct 13 ms 1736 KB Output is correct
94 Correct 42 ms 4272 KB Output is correct
95 Correct 11 ms 1460 KB Output is correct
96 Correct 24 ms 2912 KB Output is correct
97 Correct 63 ms 6508 KB Output is correct
98 Correct 77 ms 7480 KB Output is correct
99 Correct 60 ms 6216 KB Output is correct
100 Correct 21 ms 2636 KB Output is correct
101 Correct 1 ms 332 KB Output is correct
102 Correct 1 ms 332 KB Output is correct
103 Correct 23 ms 2940 KB Output is correct
104 Correct 1 ms 332 KB Output is correct
105 Correct 4 ms 680 KB Output is correct
106 Correct 6 ms 884 KB Output is correct
107 Correct 3 ms 588 KB Output is correct
108 Correct 4 ms 588 KB Output is correct
109 Correct 14 ms 1736 KB Output is correct
110 Correct 14 ms 1800 KB Output is correct
111 Correct 26 ms 3016 KB Output is correct
112 Correct 1 ms 332 KB Output is correct
113 Correct 1 ms 332 KB Output is correct
114 Correct 64 ms 6476 KB Output is correct
115 Correct 2 ms 332 KB Output is correct
116 Correct 4 ms 716 KB Output is correct
117 Correct 27 ms 2972 KB Output is correct
118 Correct 30 ms 3208 KB Output is correct
119 Correct 74 ms 7392 KB Output is correct
120 Correct 73 ms 7408 KB Output is correct
121 Correct 74 ms 7540 KB Output is correct
122 Correct 79 ms 7532 KB Output is correct
123 Correct 30 ms 3016 KB Output is correct
124 Correct 62 ms 6460 KB Output is correct
125 Correct 74 ms 7456 KB Output is correct
126 Correct 75 ms 7488 KB Output is correct
127 Correct 60 ms 6152 KB Output is correct
128 Correct 20 ms 2636 KB Output is correct