Submission #341293

# Submission time Handle Problem Language Result Execution time Memory
341293 2020-12-29T11:22:53 Z _ani Chessboard (IZhO18_chessboard) C++17
70 / 100
373 ms 262148 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
vector<ll> dv;
vector<pair<int, int>> points;
ll ans;
int main()
{
	ll n, k;
	cin >> n >> k;
	ans = n * n;
	for (int i = 1; i < n; i++)
		if (n % i == 0)dv.push_back(i);
	for (int i = 0; i < k; i++)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		for (int x = a; x <= c; x++)
			for (int y = b; y <= d; y++)
				points.push_back({ x,y });
	}/*
	for (auto p : points)
		cerr << p.first << ' ' << p.second << '\n';*/
	for (ll d : dv)
	{
		ll blackans;
		ll q = n / d;
		if (q % 2)
			blackans = (n * n - d * d) / 2 + d * d;
		else blackans = n * n / 2;
		ll whiteans = n * n - blackans;
		//cerr << blackans << ' ' << whiteans << '\n';
		for (auto p : points)
		{
			int x = p.first, y = p.second;
			if ((((x + d - 1) / d) % 2) == (((y + d - 1) / d) % 2))
			{
				//cout << "!!" << x << ' ' << y << '\n';
				blackans--;
				whiteans++;
			}
			else
			{
				blackans++;
				whiteans--;
			}
		}
		ans = min(ans, min(blackans, whiteans));
		//if (d == 2)
		//	cout << blackans << ' ' << whiteans << '\n';
	}
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 372 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 2404 KB Output is correct
2 Correct 20 ms 1004 KB Output is correct
3 Correct 51 ms 1896 KB Output is correct
4 Correct 54 ms 1776 KB Output is correct
5 Correct 73 ms 2148 KB Output is correct
6 Correct 44 ms 1768 KB Output is correct
7 Correct 10 ms 620 KB Output is correct
8 Correct 46 ms 1768 KB Output is correct
9 Correct 113 ms 3172 KB Output is correct
10 Correct 75 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 31 ms 1132 KB Output is correct
17 Correct 109 ms 2788 KB Output is correct
18 Correct 103 ms 2788 KB Output is correct
19 Correct 128 ms 2788 KB Output is correct
20 Correct 143 ms 2788 KB Output is correct
21 Correct 85 ms 2712 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 78 ms 1640 KB Output is correct
24 Correct 100 ms 2788 KB Output is correct
25 Correct 10 ms 620 KB Output is correct
26 Correct 61 ms 1852 KB Output is correct
27 Correct 72 ms 2532 KB Output is correct
28 Correct 96 ms 2788 KB Output is correct
29 Correct 33 ms 1512 KB Output is correct
30 Correct 4 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 2404 KB Output is correct
2 Correct 20 ms 1004 KB Output is correct
3 Correct 51 ms 1896 KB Output is correct
4 Correct 54 ms 1776 KB Output is correct
5 Correct 73 ms 2148 KB Output is correct
6 Correct 44 ms 1768 KB Output is correct
7 Correct 10 ms 620 KB Output is correct
8 Correct 46 ms 1768 KB Output is correct
9 Correct 113 ms 3172 KB Output is correct
10 Correct 75 ms 2020 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 31 ms 1132 KB Output is correct
27 Correct 109 ms 2788 KB Output is correct
28 Correct 103 ms 2788 KB Output is correct
29 Correct 128 ms 2788 KB Output is correct
30 Correct 143 ms 2788 KB Output is correct
31 Correct 85 ms 2712 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 78 ms 1640 KB Output is correct
34 Correct 100 ms 2788 KB Output is correct
35 Correct 10 ms 620 KB Output is correct
36 Correct 61 ms 1852 KB Output is correct
37 Correct 72 ms 2532 KB Output is correct
38 Correct 96 ms 2788 KB Output is correct
39 Correct 33 ms 1512 KB Output is correct
40 Correct 4 ms 364 KB Output is correct
41 Correct 141 ms 3300 KB Output is correct
42 Correct 123 ms 3428 KB Output is correct
43 Correct 123 ms 3192 KB Output is correct
44 Correct 124 ms 3300 KB Output is correct
45 Correct 132 ms 3552 KB Output is correct
46 Correct 177 ms 3424 KB Output is correct
47 Correct 107 ms 3300 KB Output is correct
48 Correct 141 ms 3320 KB Output is correct
49 Correct 112 ms 3300 KB Output is correct
50 Correct 373 ms 3300 KB Output is correct
51 Correct 345 ms 3556 KB Output is correct
52 Correct 328 ms 3300 KB Output is correct
53 Correct 347 ms 3424 KB Output is correct
54 Correct 326 ms 3300 KB Output is correct
55 Correct 357 ms 3616 KB Output is correct
56 Correct 307 ms 3300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 372 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 77 ms 2404 KB Output is correct
10 Correct 20 ms 1004 KB Output is correct
11 Correct 51 ms 1896 KB Output is correct
12 Correct 54 ms 1776 KB Output is correct
13 Correct 73 ms 2148 KB Output is correct
14 Correct 44 ms 1768 KB Output is correct
15 Correct 10 ms 620 KB Output is correct
16 Correct 46 ms 1768 KB Output is correct
17 Correct 113 ms 3172 KB Output is correct
18 Correct 75 ms 2020 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 3 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 31 ms 1132 KB Output is correct
35 Correct 109 ms 2788 KB Output is correct
36 Correct 103 ms 2788 KB Output is correct
37 Correct 128 ms 2788 KB Output is correct
38 Correct 143 ms 2788 KB Output is correct
39 Correct 85 ms 2712 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 78 ms 1640 KB Output is correct
42 Correct 100 ms 2788 KB Output is correct
43 Correct 10 ms 620 KB Output is correct
44 Correct 61 ms 1852 KB Output is correct
45 Correct 72 ms 2532 KB Output is correct
46 Correct 96 ms 2788 KB Output is correct
47 Correct 33 ms 1512 KB Output is correct
48 Correct 4 ms 364 KB Output is correct
49 Correct 141 ms 3300 KB Output is correct
50 Correct 123 ms 3428 KB Output is correct
51 Correct 123 ms 3192 KB Output is correct
52 Correct 124 ms 3300 KB Output is correct
53 Correct 132 ms 3552 KB Output is correct
54 Correct 177 ms 3424 KB Output is correct
55 Correct 107 ms 3300 KB Output is correct
56 Correct 141 ms 3320 KB Output is correct
57 Correct 112 ms 3300 KB Output is correct
58 Correct 373 ms 3300 KB Output is correct
59 Correct 345 ms 3556 KB Output is correct
60 Correct 328 ms 3300 KB Output is correct
61 Correct 347 ms 3424 KB Output is correct
62 Correct 326 ms 3300 KB Output is correct
63 Correct 357 ms 3616 KB Output is correct
64 Correct 307 ms 3300 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Correct 1 ms 364 KB Output is correct
67 Runtime error 296 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
68 Halted 0 ms 0 KB -