Submission #241475

# Submission time Handle Problem Language Result Execution time Memory
241475 2020-06-24T08:39:19 Z mosesmayer Vision Program (IOI19_vision) C++17
59 / 100
47 ms 4084 KB
#include "vision.h"
#include <tuple>

using namespace std;

int GH, GW;
int coord(int i, int j) {
	return i * GW + j;
};

void construct_network(int H, int W, int K) {
	tie(GH, GW) = {H, W};
//	std::vector<int> Ns;
//	Ns = {0, 1};
//	int a = add_and(Ns);
//	Ns = {0, a};
//	int b = add_or(Ns);
//	Ns = {0, 1, b};
//	int c = add_xor(Ns);
//	add_not(c);

	vector<int> left_diags_or, right_diags_or;
	vector<int> left_diags_xor, right_diags_xor;

	// Base diagonal processing
		//add left diagonals
		for (int sum = 0; sum <= H + W - 2; sum++){
			vector<int> tmp;
			for (int r = 0, c = sum; c >= 0 && r < H; r++, c--){
				if (c < W) {
					tmp.push_back(coord(r, c));
				}
			}
			if (tmp.empty()) continue;
//			printf("add left squares: ");
//			for (int i : tmp) {
//				printf("{%d, %d} ", i / W, i % W);
//			}
//			puts("");
			left_diags_or.push_back(add_or(tmp));
			left_diags_xor.push_back(add_xor(tmp));
		}

		//add right diagonals
		for (int diff = -H + 1; diff <= W; diff++) {
			vector<int> tmp;
			for (int r = H - 1, c = H - 1 + diff; r >= 0; r--, c--) {
				if (0 <= c && c < W) {
					tmp.push_back(coord(r, c));
				}
			}
			if (tmp.empty()) continue;
//			printf("add right squares: ");
//			for (int i : tmp) {
//				printf("{%d, %d} ", i / W, i % W);
//			}
//			puts("");
			right_diags_or.push_back(add_or(tmp));
			right_diags_xor.push_back(add_xor(tmp));
		}
	//

	// or -> 1 if has black pixel in diag, 0 otherwise
	// xor -> if 0 where or is 1, then 2 black in diag. if 1 then 1 black.
	//puts("start diags2");
	vector<int> left_diags_has2, right_diags_has2;
	for (int i = 0, sz = left_diags_or.size(); i < sz; i++){
		vector<int> curr = {left_diags_or[i], left_diags_xor[i]};
		left_diags_has2.push_back(add_xor(curr));
	}
	for (int i = 0, sz = right_diags_or.size(); i < sz; i++){
		vector<int> curr = {right_diags_or[i], right_diags_xor[i]};
		right_diags_has2.push_back(add_xor(curr));
	}
	//puts("add 2diags done");

	vector<int> left_k1, right_k1;
	for (int i = 0, j = K, sz = left_diags_has2.size(); j < sz; i++, j++){
		vector<int> curr;
		for (int x = i; x <= j; x++) {
			curr.push_back(left_diags_has2[x]);
		}
		int has2samecol = add_or(curr);
		curr.clear();
		for (int x = i; x <= j; x++){
			curr.push_back(left_diags_or[x]);
		}
		int has2difcol = add_xor({add_or(curr), add_xor(curr)});
		left_k1.push_back(add_or({has2samecol, has2difcol}));
	}
	for (int i = 0, j = K, sz = right_diags_has2.size(); j < sz; i++, j++){ vector<int> curr;
		for (int x = i; x <= j; x++) {
			curr.push_back(right_diags_has2[x]);
		}
		int has2samecol = add_or(curr);
		curr.clear();
		for (int x = i; x <= j; x++){
			curr.push_back(right_diags_or[x]);
		}
		int has2difcol = add_xor({add_or(curr), add_xor(curr)});
		right_k1.push_back(add_or({has2samecol, has2difcol}));
	}
	int k1val = add_and({add_or(left_k1), add_or(right_k1)});
	//puts("k1 done");


	vector<int> left_k, right_k;
	for (int i = 0, j = K - 1, sz = left_diags_has2.size(); j < sz; i++, j++){
		vector<int> curr;
		for (int x = i; x <= j; x++) {
			curr.push_back(left_diags_has2[x]);
		}
		int has2samecol = add_or(curr);
		curr.clear();
		for (int x = i; x <= j; x++){
			curr.push_back(left_diags_or[x]);
		}
		int has2difcol = add_xor({add_or(curr), add_xor(curr)});
		left_k.push_back(add_or({has2samecol, has2difcol}));
	}
	for (int i = 0, j = K - 1, sz = right_diags_has2.size(); j < sz; i++, j++){ vector<int> curr;
		for (int x = i; x <= j; x++) {
			curr.push_back(right_diags_has2[x]);
		}
		int has2samecol = add_or(curr);
		curr.clear();
		for (int x = i; x <= j; x++){
			curr.push_back(right_diags_or[x]);
		}
		int has2difcol = add_xor({add_or(curr), add_xor(curr)});
		right_k.push_back(add_or({has2samecol, has2difcol}));
	}
	int kval = add_and({add_or(left_k), add_or(right_k)});
	//puts("k done");

	add_and({k1val, add_xor({kval, k1val})});
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 7 ms 512 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 6 ms 416 KB Output is correct
34 Correct 8 ms 512 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 6 ms 512 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 7 ms 512 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 6 ms 416 KB Output is correct
34 Correct 8 ms 512 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 6 ms 512 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 22 ms 1788 KB Output is correct
39 Correct 8 ms 640 KB Output is correct
40 Correct 7 ms 512 KB Output is correct
41 Correct 10 ms 768 KB Output is correct
42 Correct 8 ms 640 KB Output is correct
43 Correct 12 ms 1020 KB Output is correct
44 Correct 21 ms 1912 KB Output is correct
45 Correct 24 ms 2040 KB Output is correct
46 Correct 21 ms 1792 KB Output is correct
47 Correct 10 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 768 KB Output is correct
2 Correct 20 ms 1536 KB Output is correct
3 Correct 20 ms 1536 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 8 ms 768 KB Output is correct
6 Correct 17 ms 1408 KB Output is correct
7 Correct 17 ms 1408 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 8 ms 768 KB Output is correct
10 Correct 17 ms 1404 KB Output is correct
11 Correct 18 ms 1536 KB Output is correct
12 Correct 19 ms 1536 KB Output is correct
13 Correct 15 ms 1280 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 8 ms 768 KB Output is correct
16 Correct 16 ms 1404 KB Output is correct
17 Correct 18 ms 1536 KB Output is correct
18 Correct 19 ms 1536 KB Output is correct
19 Correct 15 ms 1280 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 10 ms 640 KB Output is correct
4 Correct 11 ms 896 KB Output is correct
5 Correct 13 ms 1024 KB Output is correct
6 Correct 10 ms 896 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 10 ms 1024 KB Output is correct
9 Correct 16 ms 1408 KB Output is correct
10 Correct 18 ms 1536 KB Output is correct
11 Correct 16 ms 1280 KB Output is correct
12 Correct 8 ms 640 KB Output is correct
13 Correct 8 ms 768 KB Output is correct
14 Correct 18 ms 1408 KB Output is correct
15 Correct 16 ms 1408 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 8 ms 768 KB Output is correct
18 Correct 19 ms 1536 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 19 ms 1660 KB Output is correct
21 Correct 43 ms 3828 KB Output is correct
22 Correct 42 ms 3704 KB Output is correct
23 Correct 15 ms 1280 KB Output is correct
24 Correct 19 ms 1660 KB Output is correct
25 Correct 47 ms 4084 KB Output is correct
26 Correct 16 ms 1408 KB Output is correct
27 Incorrect 7 ms 1660 KB WA in grader: Too many instructions
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1660 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 7 ms 512 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 6 ms 416 KB Output is correct
34 Correct 8 ms 512 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 6 ms 512 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 22 ms 1788 KB Output is correct
39 Correct 8 ms 640 KB Output is correct
40 Correct 7 ms 512 KB Output is correct
41 Correct 10 ms 768 KB Output is correct
42 Correct 8 ms 640 KB Output is correct
43 Correct 12 ms 1020 KB Output is correct
44 Correct 21 ms 1912 KB Output is correct
45 Correct 24 ms 2040 KB Output is correct
46 Correct 21 ms 1792 KB Output is correct
47 Correct 10 ms 768 KB Output is correct
48 Correct 7 ms 768 KB Output is correct
49 Correct 20 ms 1536 KB Output is correct
50 Correct 20 ms 1536 KB Output is correct
51 Correct 6 ms 384 KB Output is correct
52 Correct 8 ms 768 KB Output is correct
53 Correct 17 ms 1408 KB Output is correct
54 Correct 17 ms 1408 KB Output is correct
55 Correct 6 ms 512 KB Output is correct
56 Correct 8 ms 768 KB Output is correct
57 Correct 17 ms 1404 KB Output is correct
58 Correct 18 ms 1536 KB Output is correct
59 Correct 19 ms 1536 KB Output is correct
60 Correct 15 ms 1280 KB Output is correct
61 Correct 6 ms 384 KB Output is correct
62 Correct 8 ms 768 KB Output is correct
63 Correct 16 ms 1404 KB Output is correct
64 Correct 18 ms 1536 KB Output is correct
65 Correct 19 ms 1536 KB Output is correct
66 Correct 15 ms 1280 KB Output is correct
67 Correct 5 ms 384 KB Output is correct
68 Correct 5 ms 384 KB Output is correct
69 Correct 5 ms 384 KB Output is correct
70 Correct 4 ms 256 KB Output is correct
71 Correct 5 ms 256 KB Output is correct
72 Correct 10 ms 640 KB Output is correct
73 Correct 11 ms 896 KB Output is correct
74 Correct 13 ms 1024 KB Output is correct
75 Correct 10 ms 896 KB Output is correct
76 Correct 7 ms 512 KB Output is correct
77 Correct 10 ms 1024 KB Output is correct
78 Correct 16 ms 1408 KB Output is correct
79 Correct 18 ms 1536 KB Output is correct
80 Correct 16 ms 1280 KB Output is correct
81 Correct 8 ms 640 KB Output is correct
82 Correct 8 ms 768 KB Output is correct
83 Correct 18 ms 1408 KB Output is correct
84 Correct 16 ms 1408 KB Output is correct
85 Correct 6 ms 384 KB Output is correct
86 Correct 8 ms 768 KB Output is correct
87 Correct 19 ms 1536 KB Output is correct
88 Correct 6 ms 384 KB Output is correct
89 Correct 19 ms 1660 KB Output is correct
90 Correct 43 ms 3828 KB Output is correct
91 Correct 42 ms 3704 KB Output is correct
92 Correct 15 ms 1280 KB Output is correct
93 Correct 19 ms 1660 KB Output is correct
94 Correct 47 ms 4084 KB Output is correct
95 Correct 16 ms 1408 KB Output is correct
96 Incorrect 7 ms 1660 KB WA in grader: Too many instructions
97 Halted 0 ms 0 KB -