Submission #378519

# Submission time Handle Problem Language Result Execution time Memory
378519 2021-03-17T01:22:13 Z casperwang Chessboard (IZhO18_chessboard) C++14
70 / 100
2000 ms 748 KB
#include <bits/stdc++.h>
#define int long long
#define pb emplace_back
#define y1 y_1
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }

const int MAXN = 100000;
int N, K;
int x1, y1, x2, y2;
vector <int> fac;
vector <vector<int>> c;
int cnt, ans;

void init() {
	for (int i = 1; i < N; i++)
		if (N % i == 0) fac.pb(i);
	c.resize(fac.size());
	for (vector <int> &v : c)
		v.resize(2);
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> N >> K;
	init();
	for (int i = 0; i < K; i++) {
		cin >> x1 >> y1 >> x2 >> y2;
		for (int x = x1; x <= x2; x++) {
			for (int y = y1; y <= y2; y++) {
				int id = 0;
				for (int p : fac) {
					int t = ((x+p-1) / p) + ((y+p-1) / p);
					c[id++][t & 1]++, cnt++;
				}
			}
		}
	}
	ans = N * N;
	cnt /= fac.size();
	int id = 0;
	for (int p : fac) {
		int m1 = (N / p) * (N / p) / 2 * p * p;
		int m0 = N * N - m1;
		// debug(p, m0, m1);
		// debug(m1 - c[id][1] + c[id][0]);
		// debug(m0 - c[id][0] + c[id][1]);
		ans = min(ans, m1 - c[id][1] + c[id][0]);
		ans = min(ans, m0 - c[id][0] + c[id][1]);
		id++;
	}
	cout << ans << '\n';
}
# 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 0 ms 364 KB Output is correct
4 Correct 0 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 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 492 KB Output is correct
2 Correct 7 ms 620 KB Output is correct
3 Correct 15 ms 620 KB Output is correct
4 Correct 16 ms 620 KB Output is correct
5 Correct 21 ms 620 KB Output is correct
6 Correct 15 ms 748 KB Output is correct
7 Correct 4 ms 492 KB Output is correct
8 Correct 14 ms 620 KB Output is correct
9 Correct 34 ms 620 KB Output is correct
10 Correct 20 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 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 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 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 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 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 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 10 ms 492 KB Output is correct
17 Correct 29 ms 512 KB Output is correct
18 Correct 36 ms 636 KB Output is correct
19 Correct 64 ms 492 KB Output is correct
20 Correct 71 ms 620 KB Output is correct
21 Correct 26 ms 492 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 17 ms 492 KB Output is correct
24 Correct 31 ms 492 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 20 ms 620 KB Output is correct
27 Correct 26 ms 492 KB Output is correct
28 Correct 33 ms 492 KB Output is correct
29 Correct 11 ms 620 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 492 KB Output is correct
2 Correct 7 ms 620 KB Output is correct
3 Correct 15 ms 620 KB Output is correct
4 Correct 16 ms 620 KB Output is correct
5 Correct 21 ms 620 KB Output is correct
6 Correct 15 ms 748 KB Output is correct
7 Correct 4 ms 492 KB Output is correct
8 Correct 14 ms 620 KB Output is correct
9 Correct 34 ms 620 KB Output is correct
10 Correct 20 ms 620 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 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 1 ms 384 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 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 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 10 ms 492 KB Output is correct
27 Correct 29 ms 512 KB Output is correct
28 Correct 36 ms 636 KB Output is correct
29 Correct 64 ms 492 KB Output is correct
30 Correct 71 ms 620 KB Output is correct
31 Correct 26 ms 492 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 17 ms 492 KB Output is correct
34 Correct 31 ms 492 KB Output is correct
35 Correct 4 ms 364 KB Output is correct
36 Correct 20 ms 620 KB Output is correct
37 Correct 26 ms 492 KB Output is correct
38 Correct 33 ms 492 KB Output is correct
39 Correct 11 ms 620 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 62 ms 620 KB Output is correct
42 Correct 39 ms 748 KB Output is correct
43 Correct 48 ms 620 KB Output is correct
44 Correct 37 ms 748 KB Output is correct
45 Correct 36 ms 748 KB Output is correct
46 Correct 68 ms 748 KB Output is correct
47 Correct 32 ms 620 KB Output is correct
48 Correct 42 ms 620 KB Output is correct
49 Correct 34 ms 620 KB Output is correct
50 Correct 224 ms 640 KB Output is correct
51 Correct 239 ms 748 KB Output is correct
52 Correct 219 ms 620 KB Output is correct
53 Correct 234 ms 620 KB Output is correct
54 Correct 217 ms 748 KB Output is correct
55 Correct 245 ms 748 KB Output is correct
56 Correct 211 ms 748 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 0 ms 364 KB Output is correct
4 Correct 0 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 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 24 ms 492 KB Output is correct
10 Correct 7 ms 620 KB Output is correct
11 Correct 15 ms 620 KB Output is correct
12 Correct 16 ms 620 KB Output is correct
13 Correct 21 ms 620 KB Output is correct
14 Correct 15 ms 748 KB Output is correct
15 Correct 4 ms 492 KB Output is correct
16 Correct 14 ms 620 KB Output is correct
17 Correct 34 ms 620 KB Output is correct
18 Correct 20 ms 620 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 0 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 384 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 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 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 10 ms 492 KB Output is correct
35 Correct 29 ms 512 KB Output is correct
36 Correct 36 ms 636 KB Output is correct
37 Correct 64 ms 492 KB Output is correct
38 Correct 71 ms 620 KB Output is correct
39 Correct 26 ms 492 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 17 ms 492 KB Output is correct
42 Correct 31 ms 492 KB Output is correct
43 Correct 4 ms 364 KB Output is correct
44 Correct 20 ms 620 KB Output is correct
45 Correct 26 ms 492 KB Output is correct
46 Correct 33 ms 492 KB Output is correct
47 Correct 11 ms 620 KB Output is correct
48 Correct 1 ms 364 KB Output is correct
49 Correct 62 ms 620 KB Output is correct
50 Correct 39 ms 748 KB Output is correct
51 Correct 48 ms 620 KB Output is correct
52 Correct 37 ms 748 KB Output is correct
53 Correct 36 ms 748 KB Output is correct
54 Correct 68 ms 748 KB Output is correct
55 Correct 32 ms 620 KB Output is correct
56 Correct 42 ms 620 KB Output is correct
57 Correct 34 ms 620 KB Output is correct
58 Correct 224 ms 640 KB Output is correct
59 Correct 239 ms 748 KB Output is correct
60 Correct 219 ms 620 KB Output is correct
61 Correct 234 ms 620 KB Output is correct
62 Correct 217 ms 748 KB Output is correct
63 Correct 245 ms 748 KB Output is correct
64 Correct 211 ms 748 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Correct 1 ms 364 KB Output is correct
67 Execution timed out 2062 ms 492 KB Time limit exceeded
68 Halted 0 ms 0 KB -