Submission #855851

# Submission time Handle Problem Language Result Execution time Memory
855851 2023-10-02T03:22:13 Z Trisanu_Das Chessboard (IZhO18_chessboard) C++17
100 / 100
347 ms 5904 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main() {
	int n, k; cin >> n >> k;
	int ans = n * n;
	array<int, 4> a[k];
	for(auto &[i, j, k, l] : a) cin >> i >> j >> k >> l;
	for(int m = 1; m < n; m++) if(!(n % m)) {
#define c(V) (m * ((V) / (2 * m)) + min(m, (V) % (2 * m)))
		int t = c(n) * (n - c(n)) + c(n) * (n - c(n));
		for(auto [i, j, k, l] : a) {
			int u = k - i + 1, x = c(k) - c(i - 1);
			int v = l - j + 1, y = c(l) - c(j - 1);
			t += 2 * (x * y + (u - x) * (v - y)) - u * v;
		}
		ans = min(ans, min(t, n * n - t));
	}
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2140 KB Output is correct
2 Correct 12 ms 856 KB Output is correct
3 Correct 31 ms 1624 KB Output is correct
4 Correct 31 ms 1624 KB Output is correct
5 Correct 42 ms 1884 KB Output is correct
6 Correct 27 ms 1372 KB Output is correct
7 Correct 6 ms 604 KB Output is correct
8 Correct 27 ms 1516 KB Output is correct
9 Correct 68 ms 3164 KB Output is correct
10 Correct 39 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 17 ms 1292 KB Output is correct
17 Correct 49 ms 2908 KB Output is correct
18 Correct 62 ms 3420 KB Output is correct
19 Correct 95 ms 3172 KB Output is correct
20 Correct 106 ms 3416 KB Output is correct
21 Correct 47 ms 2908 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 32 ms 1628 KB Output is correct
24 Correct 59 ms 3164 KB Output is correct
25 Correct 7 ms 600 KB Output is correct
26 Correct 36 ms 2140 KB Output is correct
27 Correct 45 ms 2396 KB Output is correct
28 Correct 59 ms 3164 KB Output is correct
29 Correct 20 ms 1368 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2140 KB Output is correct
2 Correct 12 ms 856 KB Output is correct
3 Correct 31 ms 1624 KB Output is correct
4 Correct 31 ms 1624 KB Output is correct
5 Correct 42 ms 1884 KB Output is correct
6 Correct 27 ms 1372 KB Output is correct
7 Correct 6 ms 604 KB Output is correct
8 Correct 27 ms 1516 KB Output is correct
9 Correct 68 ms 3164 KB Output is correct
10 Correct 39 ms 1884 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 17 ms 1292 KB Output is correct
27 Correct 49 ms 2908 KB Output is correct
28 Correct 62 ms 3420 KB Output is correct
29 Correct 95 ms 3172 KB Output is correct
30 Correct 106 ms 3416 KB Output is correct
31 Correct 47 ms 2908 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 32 ms 1628 KB Output is correct
34 Correct 59 ms 3164 KB Output is correct
35 Correct 7 ms 600 KB Output is correct
36 Correct 36 ms 2140 KB Output is correct
37 Correct 45 ms 2396 KB Output is correct
38 Correct 59 ms 3164 KB Output is correct
39 Correct 20 ms 1368 KB Output is correct
40 Correct 2 ms 348 KB Output is correct
41 Correct 103 ms 2904 KB Output is correct
42 Correct 77 ms 3164 KB Output is correct
43 Correct 82 ms 2908 KB Output is correct
44 Correct 77 ms 3164 KB Output is correct
45 Correct 78 ms 3420 KB Output is correct
46 Correct 115 ms 3164 KB Output is correct
47 Correct 68 ms 2908 KB Output is correct
48 Correct 81 ms 2904 KB Output is correct
49 Correct 69 ms 2904 KB Output is correct
50 Correct 308 ms 3240 KB Output is correct
51 Correct 326 ms 3420 KB Output is correct
52 Correct 305 ms 3160 KB Output is correct
53 Correct 326 ms 3420 KB Output is correct
54 Correct 303 ms 3184 KB Output is correct
55 Correct 337 ms 3528 KB Output is correct
56 Correct 291 ms 3100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 48 ms 2140 KB Output is correct
10 Correct 12 ms 856 KB Output is correct
11 Correct 31 ms 1624 KB Output is correct
12 Correct 31 ms 1624 KB Output is correct
13 Correct 42 ms 1884 KB Output is correct
14 Correct 27 ms 1372 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 27 ms 1516 KB Output is correct
17 Correct 68 ms 3164 KB Output is correct
18 Correct 39 ms 1884 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 17 ms 1292 KB Output is correct
35 Correct 49 ms 2908 KB Output is correct
36 Correct 62 ms 3420 KB Output is correct
37 Correct 95 ms 3172 KB Output is correct
38 Correct 106 ms 3416 KB Output is correct
39 Correct 47 ms 2908 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 32 ms 1628 KB Output is correct
42 Correct 59 ms 3164 KB Output is correct
43 Correct 7 ms 600 KB Output is correct
44 Correct 36 ms 2140 KB Output is correct
45 Correct 45 ms 2396 KB Output is correct
46 Correct 59 ms 3164 KB Output is correct
47 Correct 20 ms 1368 KB Output is correct
48 Correct 2 ms 348 KB Output is correct
49 Correct 103 ms 2904 KB Output is correct
50 Correct 77 ms 3164 KB Output is correct
51 Correct 82 ms 2908 KB Output is correct
52 Correct 77 ms 3164 KB Output is correct
53 Correct 78 ms 3420 KB Output is correct
54 Correct 115 ms 3164 KB Output is correct
55 Correct 68 ms 2908 KB Output is correct
56 Correct 81 ms 2904 KB Output is correct
57 Correct 69 ms 2904 KB Output is correct
58 Correct 308 ms 3240 KB Output is correct
59 Correct 326 ms 3420 KB Output is correct
60 Correct 305 ms 3160 KB Output is correct
61 Correct 326 ms 3420 KB Output is correct
62 Correct 303 ms 3184 KB Output is correct
63 Correct 337 ms 3528 KB Output is correct
64 Correct 291 ms 3100 KB Output is correct
65 Correct 0 ms 600 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 318 ms 5380 KB Output is correct
68 Correct 316 ms 5712 KB Output is correct
69 Correct 278 ms 4852 KB Output is correct
70 Correct 312 ms 5204 KB Output is correct
71 Correct 309 ms 5460 KB Output is correct
72 Correct 301 ms 5140 KB Output is correct
73 Correct 292 ms 5096 KB Output is correct
74 Correct 316 ms 5468 KB Output is correct
75 Correct 304 ms 5460 KB Output is correct
76 Correct 326 ms 5508 KB Output is correct
77 Correct 107 ms 5712 KB Output is correct
78 Correct 76 ms 5328 KB Output is correct
79 Correct 86 ms 4828 KB Output is correct
80 Correct 89 ms 5340 KB Output is correct
81 Correct 85 ms 4916 KB Output is correct
82 Correct 86 ms 5776 KB Output is correct
83 Correct 76 ms 4948 KB Output is correct
84 Correct 218 ms 5716 KB Output is correct
85 Correct 333 ms 5820 KB Output is correct
86 Correct 2 ms 344 KB Output is correct
87 Correct 1 ms 348 KB Output is correct
88 Correct 347 ms 5904 KB Output is correct
89 Correct 65 ms 1372 KB Output is correct
90 Correct 1 ms 432 KB Output is correct