Submission #146336

# Submission time Handle Problem Language Result Execution time Memory
146336 2019-08-23T14:05:54 Z jwvg0425 Vision Program (IOI19_vision) C++17
0 / 100
11 ms 1264 KB
#include "vision.h"
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int h, w, k;

int cell(int x, int y)
{
	return y * w + x;
}

vector<int> allXCell(int y)
{
	vector<int> xs;

	for (int x = 0; x < w; x++)
		xs.push_back(cell(x, y));

	return xs;
}

vector<int> allYCell(int x)
{
	vector<int> ys;

	for (int y = 0; y < h; y++)
		ys.push_back(cell(x, y));

	return ys;
}

vector<int> range(int s, int e)
{
	vector<int> v;

	for (int i = s; i <= e; i++)
		v.push_back(i);

	return v;
}

int xcell(int x)
{
	return h * w + x;
}

int ycell(int y)
{
	return h * w + w + y;
}

int xd[205];
int yd[205];

void brute()
{
	int inst = 0;

	for (int y1 = 0; y1 < h; y1++)
	{
		for (int x1 = 0; x1 < w; x1++)
		{
			int a = y1 * w + x1;
			for (int y2 = 0; y2 < h; y2++)
			{
				for (int x2 = 0; x2 < w; x2++)
				{
					if (abs(x1 - x2) + abs(y1 - y2) != k)
						continue;

					int b = y2 * w + x2;
					add_and({ a, b });
					inst++;
				}
			}
		}
	}

	vector<int> ors;

	for (int i = 0; i < inst; i++)
		ors.push_back(h * w + i);

	add_or(ors);
}

void construct_network(int H, int W, int K) {
	if (min(H, W) == 1)
	{
		brute();
		return;
	}

	memset(xd, -1, sizeof(xd));
	memset(yd, -1, sizeof(yd));

	h = H; w = W; k = K;

	for (int x = 0; x < W; x++)
		add_or(allYCell(x));

	for (int y = 0; y < H; y++)
		add_or(allXCell(y));

	xd[0] = add_xor(range(xcell(0), xcell(w - 1))); // x1 == x2 검사 셀
	yd[0] = add_xor(range(ycell(0), ycell(h - 1))); // y1 == y2 검사 셀

	for (int d = 1; d <= min(k, W - 1); d++)
	{
		vector<int> c;

		for (int x = 0; x < W - d; x++)
			c.push_back(add_and({ xcell(x), xcell(x + d) }));
		
		xd[d] = add_or(c);
	}

	for (int d = 1; d <= min(k, H - 1); d++)
	{
		vector<int> c;

		for (int y = 0; y < H - d; y++)
			c.push_back(add_and({ ycell(y), ycell(y + d) }));

		yd[d] = add_or(c);
	}

	vector<int> check;
	for (int xk = 0; xk <= k; xk++)
	{
		int yk = k - xk;

		if (xd[xk] == -1 || yd[yk] == -1)
			continue;

		check.push_back(add_and({ xd[xk], yd[yk] }));
	}

	add_or(check);
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 256 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 6 ms 760 KB Output is correct
6 Correct 6 ms 856 KB Output is correct
7 Correct 6 ms 884 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 8 ms 1032 KB Output is correct
10 Correct 9 ms 1264 KB Output is correct
11 Incorrect 4 ms 1140 KB WA in grader: Too many instructions
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1144 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB WA in grader: Instruction with no inputs
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -