Submission #47264

# Submission time Handle Problem Language Result Execution time Memory
47264 2018-04-30T02:52:27 Z jun6873 Chessboard (IZhO18_chessboard) C++11
70 / 100
382 ms 61344 KB
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long lint;

const int maxn = 100004;
int n, k, x1[maxn], y1[maxn], x2[maxn], y2[maxn];
lint s;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> n >> k;
	for (int i=0; i<k; i++) {
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		x1[i]--; y1[i]--; x2[i]--; y2[i]--;
		s += (x2[i] - x1[i] + 1) * (lint)(y2[i] - y1[i] + 1);
	}

	lint ans = 1ll << 50;
	for (lint i=1; i<n; i++) if (n%i == 0) {
		lint t = 0, a, b;
		a = ((n/i) * (n/i) + 1) / 2 * i * i;
		b = ((n/i) * (n/i)) / 2 * i * i;
		for (int j=0; j<k; j++) {
			if ((x1[j]/i) % 2 == (y1[j]/i) % 2) t++;
		}

		ans = min(ans, (a - t) + (s-t));
		ans = min(ans, (b - (s-t)) + t);
	}

	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 400 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 520 KB Output is correct
7 Correct 2 ms 540 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3072 KB Output is correct
2 Correct 9 ms 3072 KB Output is correct
3 Correct 24 ms 4048 KB Output is correct
4 Correct 20 ms 5116 KB Output is correct
5 Correct 26 ms 6616 KB Output is correct
6 Correct 17 ms 7028 KB Output is correct
7 Correct 6 ms 7028 KB Output is correct
8 Correct 17 ms 8168 KB Output is correct
9 Correct 43 ms 11032 KB Output is correct
10 Correct 24 ms 11648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11648 KB Output is correct
2 Correct 2 ms 11648 KB Output is correct
3 Correct 2 ms 11648 KB Output is correct
4 Correct 2 ms 11648 KB Output is correct
5 Correct 2 ms 11648 KB Output is correct
6 Correct 2 ms 11648 KB Output is correct
7 Correct 2 ms 11648 KB Output is correct
8 Correct 2 ms 11648 KB Output is correct
9 Correct 2 ms 11648 KB Output is correct
10 Correct 2 ms 11648 KB Output is correct
11 Correct 2 ms 11648 KB Output is correct
12 Correct 2 ms 11648 KB Output is correct
13 Correct 2 ms 11648 KB Output is correct
14 Correct 2 ms 11648 KB Output is correct
15 Correct 2 ms 11648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11648 KB Output is correct
2 Correct 2 ms 11648 KB Output is correct
3 Correct 2 ms 11648 KB Output is correct
4 Correct 2 ms 11648 KB Output is correct
5 Correct 2 ms 11648 KB Output is correct
6 Correct 2 ms 11648 KB Output is correct
7 Correct 2 ms 11648 KB Output is correct
8 Correct 2 ms 11648 KB Output is correct
9 Correct 2 ms 11648 KB Output is correct
10 Correct 2 ms 11648 KB Output is correct
11 Correct 2 ms 11648 KB Output is correct
12 Correct 2 ms 11648 KB Output is correct
13 Correct 2 ms 11648 KB Output is correct
14 Correct 2 ms 11648 KB Output is correct
15 Correct 2 ms 11648 KB Output is correct
16 Correct 13 ms 11924 KB Output is correct
17 Correct 31 ms 14092 KB Output is correct
18 Correct 42 ms 15840 KB Output is correct
19 Correct 92 ms 17184 KB Output is correct
20 Correct 102 ms 18884 KB Output is correct
21 Correct 35 ms 19968 KB Output is correct
22 Correct 2 ms 19968 KB Output is correct
23 Correct 23 ms 20012 KB Output is correct
24 Correct 41 ms 22232 KB Output is correct
25 Correct 6 ms 22232 KB Output is correct
26 Correct 42 ms 22764 KB Output is correct
27 Correct 33 ms 24124 KB Output is correct
28 Correct 40 ms 25992 KB Output is correct
29 Correct 15 ms 25992 KB Output is correct
30 Correct 3 ms 25992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3072 KB Output is correct
2 Correct 9 ms 3072 KB Output is correct
3 Correct 24 ms 4048 KB Output is correct
4 Correct 20 ms 5116 KB Output is correct
5 Correct 26 ms 6616 KB Output is correct
6 Correct 17 ms 7028 KB Output is correct
7 Correct 6 ms 7028 KB Output is correct
8 Correct 17 ms 8168 KB Output is correct
9 Correct 43 ms 11032 KB Output is correct
10 Correct 24 ms 11648 KB Output is correct
11 Correct 2 ms 11648 KB Output is correct
12 Correct 2 ms 11648 KB Output is correct
13 Correct 2 ms 11648 KB Output is correct
14 Correct 2 ms 11648 KB Output is correct
15 Correct 2 ms 11648 KB Output is correct
16 Correct 2 ms 11648 KB Output is correct
17 Correct 2 ms 11648 KB Output is correct
18 Correct 2 ms 11648 KB Output is correct
19 Correct 2 ms 11648 KB Output is correct
20 Correct 2 ms 11648 KB Output is correct
21 Correct 2 ms 11648 KB Output is correct
22 Correct 2 ms 11648 KB Output is correct
23 Correct 2 ms 11648 KB Output is correct
24 Correct 2 ms 11648 KB Output is correct
25 Correct 2 ms 11648 KB Output is correct
26 Correct 13 ms 11924 KB Output is correct
27 Correct 31 ms 14092 KB Output is correct
28 Correct 42 ms 15840 KB Output is correct
29 Correct 92 ms 17184 KB Output is correct
30 Correct 102 ms 18884 KB Output is correct
31 Correct 35 ms 19968 KB Output is correct
32 Correct 2 ms 19968 KB Output is correct
33 Correct 23 ms 20012 KB Output is correct
34 Correct 41 ms 22232 KB Output is correct
35 Correct 6 ms 22232 KB Output is correct
36 Correct 42 ms 22764 KB Output is correct
37 Correct 33 ms 24124 KB Output is correct
38 Correct 40 ms 25992 KB Output is correct
39 Correct 15 ms 25992 KB Output is correct
40 Correct 3 ms 25992 KB Output is correct
41 Correct 83 ms 28512 KB Output is correct
42 Correct 52 ms 30904 KB Output is correct
43 Correct 64 ms 32908 KB Output is correct
44 Correct 46 ms 35064 KB Output is correct
45 Correct 50 ms 37504 KB Output is correct
46 Correct 94 ms 39780 KB Output is correct
47 Correct 51 ms 41604 KB Output is correct
48 Correct 55 ms 43796 KB Output is correct
49 Correct 52 ms 45736 KB Output is correct
50 Correct 336 ms 48172 KB Output is correct
51 Correct 348 ms 50588 KB Output is correct
52 Correct 331 ms 52516 KB Output is correct
53 Correct 361 ms 54796 KB Output is correct
54 Correct 322 ms 57024 KB Output is correct
55 Correct 382 ms 59472 KB Output is correct
56 Correct 321 ms 61344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 400 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 520 KB Output is correct
7 Correct 2 ms 540 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 33 ms 3072 KB Output is correct
10 Correct 9 ms 3072 KB Output is correct
11 Correct 24 ms 4048 KB Output is correct
12 Correct 20 ms 5116 KB Output is correct
13 Correct 26 ms 6616 KB Output is correct
14 Correct 17 ms 7028 KB Output is correct
15 Correct 6 ms 7028 KB Output is correct
16 Correct 17 ms 8168 KB Output is correct
17 Correct 43 ms 11032 KB Output is correct
18 Correct 24 ms 11648 KB Output is correct
19 Correct 2 ms 11648 KB Output is correct
20 Correct 2 ms 11648 KB Output is correct
21 Correct 2 ms 11648 KB Output is correct
22 Correct 2 ms 11648 KB Output is correct
23 Correct 2 ms 11648 KB Output is correct
24 Correct 2 ms 11648 KB Output is correct
25 Correct 2 ms 11648 KB Output is correct
26 Correct 2 ms 11648 KB Output is correct
27 Correct 2 ms 11648 KB Output is correct
28 Correct 2 ms 11648 KB Output is correct
29 Correct 2 ms 11648 KB Output is correct
30 Correct 2 ms 11648 KB Output is correct
31 Correct 2 ms 11648 KB Output is correct
32 Correct 2 ms 11648 KB Output is correct
33 Correct 2 ms 11648 KB Output is correct
34 Correct 13 ms 11924 KB Output is correct
35 Correct 31 ms 14092 KB Output is correct
36 Correct 42 ms 15840 KB Output is correct
37 Correct 92 ms 17184 KB Output is correct
38 Correct 102 ms 18884 KB Output is correct
39 Correct 35 ms 19968 KB Output is correct
40 Correct 2 ms 19968 KB Output is correct
41 Correct 23 ms 20012 KB Output is correct
42 Correct 41 ms 22232 KB Output is correct
43 Correct 6 ms 22232 KB Output is correct
44 Correct 42 ms 22764 KB Output is correct
45 Correct 33 ms 24124 KB Output is correct
46 Correct 40 ms 25992 KB Output is correct
47 Correct 15 ms 25992 KB Output is correct
48 Correct 3 ms 25992 KB Output is correct
49 Correct 83 ms 28512 KB Output is correct
50 Correct 52 ms 30904 KB Output is correct
51 Correct 64 ms 32908 KB Output is correct
52 Correct 46 ms 35064 KB Output is correct
53 Correct 50 ms 37504 KB Output is correct
54 Correct 94 ms 39780 KB Output is correct
55 Correct 51 ms 41604 KB Output is correct
56 Correct 55 ms 43796 KB Output is correct
57 Correct 52 ms 45736 KB Output is correct
58 Correct 336 ms 48172 KB Output is correct
59 Correct 348 ms 50588 KB Output is correct
60 Correct 331 ms 52516 KB Output is correct
61 Correct 361 ms 54796 KB Output is correct
62 Correct 322 ms 57024 KB Output is correct
63 Correct 382 ms 59472 KB Output is correct
64 Correct 321 ms 61344 KB Output is correct
65 Correct 2 ms 61344 KB Output is correct
66 Incorrect 2 ms 61344 KB Output isn't correct
67 Halted 0 ms 0 KB -