Submission #498221

# Submission time Handle Problem Language Result Execution time Memory
498221 2021-12-24T15:50:59 Z sireanu_vlad Chessboard (IZhO18_chessboard) C++14
0 / 100
2 ms 556 KB
#include <iostream>
using namespace std;

int n, k, t;
bool v[10001][10001];

void read()
{
	cin >> n >> k;
	int a, b, c, d;
	for(int i = 0; i < k; ++i)
	{
		cin >> a >> b >> c >> d;
		for(int j = a; j <= c; ++j)
			for(int l = b; l <= d; ++l)
				v[j][l] = 1;
	}
}

void setZero(int I, int J, int l)
{
	for(int i = I; i < I+l; ++i)
		for(int j = J; j < J+l; ++j)
			if(v[i][j]) t++;
}

void setOne(int I, int J, int l)
{
	for(int i = I; i < I+l; ++i)
		for(int j = J; j < J+l; ++j)
			if(!v[i][j]) t++;
}

int v1(int l)
{
	t = 0;
	for(int i = 1; i <= n; i += l)
		for(int j = 1; j <= n; j += l)
		{
			if((i-j) % (2*l))
				setOne(i, j, l);
			else setZero(i, j, l);
		}
	return t;
}

int v2(int l)
{
	t = 0;
	for(int i = 1; i <= n; i += l)
		for(int j = 1; j <= n; j += l)
		{
			if((i-j) % (2*l))
				setZero(i, j, l);
			else setOne(i, j, l);
		}
	return t;
}

void chess()
{
	int pmin = 2e9;
	for(int l = 1; l <= n/2; ++l)
		pmin = min(pmin, min(v1(l), v2(l)));
	cout << pmin;
}

void afis()
{
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
			cout << v[i][j] << ' ';
		cout << '\n';
	}
}

int main()
{
	read();
	chess();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 2 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 556 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 2 ms 460 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 556 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 2 ms 460 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 2 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -