Submission #298561

# Submission time Handle Problem Language Result Execution time Memory
298561 2020-09-13T07:03:05 Z square1001 Vision Program (IOI19_vision) C++14
12 / 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(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(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 + 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 384 KB Output is correct
5 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 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 384 KB Output is correct
5 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 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 384 KB Output is correct
5 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# 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 384 KB Output is correct
5 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 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 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 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 1 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 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1152 KB on inputs (14, 10), (15, 8), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 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 384 KB Output is correct
5 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -