Submission #298562

# Submission time Handle Problem Language Result Execution time Memory
298562 2020-09-13T07:06:02 Z square1001 Vision Program (IOI19_vision) C++14
66 / 100
11 ms 1152 KB
#include "vision.h"
#include <vector>
#include <algorithm>
using namespace std;
void construct_network(int H, int W, int K) {
	if(H == 1 || W == 1) {
		vector<int> elems;
		for(int i = 0; i < H * W - K; ++i) {
			add_and({i, i + K});
			elems.push_back(H * W + i);
		}
		add_or(elems);
	}
	else if(K == 1) {
		vector<int> elemsx, elemsy;
		for(int i = 0; i < H; ++i) {
			vector<int> elems;
			for(int j = 0; j < W; ++j) {
				elems.push_back(i * W + j);
			}
			add_xor(elems);
			elemsx.push_back(H * W + i);
		}
		for(int i = 0; i < W; ++i) {
			vector<int> elems;
			for(int j = 0; j < H; ++j) {
				elems.push_back(j * W + i);
			}
			add_xor(elems);
			elemsy.push_back(H * W + H + i);
		}
		vector<int> elemx, elemy;
		for(int i = 0; i < H - 1; ++i) {
			add_and({H * W + i, H * W + i + 1});
			elemx.push_back(H * W + H + W + i);
		}
		for(int i = 0; i < W - 1; ++i) {
			add_and({H * W + H + i, H * W + H + i + 1});
			elemy.push_back(H * W + H + W + (H - 1) + i);
		}
		int qs = H * W + H + W + (H - 1) + (W - 1);
		add_or(elemsx);
		add_not(qs);
		add_or(elemsy);
		add_not(qs + 2);
		add_or(elemx);
		add_or(elemy);
		add_and({qs + 1, qs + 5});
		add_and({qs + 3, qs + 4});
		add_or({qs + 6, qs + 7});
	}
	else if(H * W + H + W + H * (H - 1) / 2 + W * (W - 1) / 2 + (H + 1) + (W + 1) + min(H, W) <= 10000) {
		for(int i = 0; i < H; ++i) {
			vector<int> elems;
			for(int j = 0; j < W; ++j) {
				elems.push_back(i * W + j);
			}
			add_xor(elems);
		}
		for(int i = 0; i < W; ++i) {
			vector<int> elems;
			for(int j = 0; j < H; ++j) {
				elems.push_back(j * W + i);
			}
			add_xor(elems);
		}
		vector<int> ax, ay;
		for(int i = 0; i < H; ++i) {
			for(int j = i + 1; j < H; ++j) {
				add_and({H * W + i, H * W + j});
				ax.push_back(j - i);
			}
		}
		for(int i = 0; i < W; ++i) {
			for(int j = i + 1; j < W; ++j) {
				add_and({H * W + H + i, H * W + H + j});
				ay.push_back(j - i);
			}
		}
		int qs = H * W + H + W + H * (H - 1) / 2 + W * (W - 1) / 2;
		for(int i = 0; i < H; ++i) {
			if(i == 0) {
				vector<int> elems;
				for(int j = 0; j < int(ax.size()); ++j) {
					elems.push_back(H * W + H + W + j);
				}
				add_or(elems);
				add_not(qs);
			}
			else {
				vector<int> elems;
				for(int j = 0; j < int(ax.size()); ++j) {
					if(ax[j] == i) {
						elems.push_back(H * W + H + W + j);
					}
				}
				add_or(elems);
			}
		}
		for(int i = 0; i < W; ++i) {
			if(i == 0) {
				vector<int> elems;
				for(int j = 0; j < int(ay.size()); ++j) {
					elems.push_back(H * W + H + W + H * (H - 1) / 2 + j);
				}
				add_or(elems);
				add_not(qs + (H + 1));
			}
			else {
				vector<int> elems;
				for(int j = 0; j < int(ay.size()); ++j) {
					if(ay[j] == i) {
						elems.push_back(H * W + H + W + H * (H - 1) / 2 + j);
					}
				}
				add_or(elems);
			}
		}
		int cnt = 0;
		for(int i = 0; i < H; ++i) {
			for(int j = 0; j < W; ++j) {
				if(i + j == K) {
					add_and({qs + i + 1, qs + (H + 1) + j + 1});
					++cnt;
				}
			}
		}
		vector<int> felems;
		for(int i = 0; i < cnt; ++i) {
			felems.push_back(qs + (H + 1) + (W + 1) + i);
		}
		add_or(felems);
	}
	else {
		vector<int> elems;
		for(int i = 0; i < H; ++i) {
			for(int j = 0; j < W; ++j) {
				if(i + j == K) {
					elems.push_back(i * W + j);
				}
			}
		}
		add_or(elems);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 416 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 416 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Incorrect 1 ms 256 KB on inputs (8, 61), (22, 97), expected 1, but computed 0
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 288 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 7 ms 892 KB Output is correct
5 Correct 7 ms 892 KB Output is correct
6 Correct 7 ms 892 KB Output is correct
7 Correct 7 ms 892 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 6 ms 744 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 6 ms 768 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 11 ms 1152 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 0 ms 256 KB Output is correct
32 Correct 0 ms 256 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1152 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 6 ms 768 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 11 ms 1152 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 416 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Incorrect 1 ms 256 KB on inputs (8, 61), (22, 97), expected 1, but computed 0
39 Halted 0 ms 0 KB -