Submission #768770

# Submission time Handle Problem Language Result Execution time Memory
768770 2023-06-28T14:59:16 Z rainboy Chessboard (IZhO18_chessboard) C
100 / 100
290 ms 4228 KB
#include <stdio.h>

#define N	100000
#define INF	0x3f3f3f3f3f3f3f3fLL

long long min(long long a, long long b) { return a < b ? a : b; }

int f(int s, int a) {
	a %= s * 2;
	return min(a, s * 2 - a);
}

int main() {
	static int xx1[N], yy1[N], xx2[N], yy2[N];
	int n, s, t, i;
	long long k, k_;

	scanf("%d%d", &s, &n);
	for (i = 0; i < n; i++)
		scanf("%d%d%d%d", &xx1[i], &yy1[i], &xx2[i], &yy2[i]), xx1[i]--, yy1[i]--;
	k_ = INF;
	for (t = 1; t < s; t++)
		if (s % t == 0) {
			k = (long long) (s / t) * (s / t) / 2 * t * t;
			for (i = 0; i < n; i++)
				k += (long long) (f(t, xx2[i]) - f(t, xx1[i])) * (f(t, yy2[i]) - f(t, yy1[i]));
			k_ = min(k_, min(k, (long long) s * s - k));
		}
	printf("%lld\n", k_);
	return 0;
}

Compilation message

chessboard.c: In function 'main':
chessboard.c:18:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d%d", &s, &n);
      |  ^~~~~~~~~~~~~~~~~~~~~
chessboard.c:20:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d%d%d%d", &xx1[i], &yy1[i], &xx2[i], &yy2[i]), xx1[i]--, yy1[i]--;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 264 KB Output is correct
5 Correct 1 ms 240 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2644 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 12 ms 1768 KB Output is correct
4 Correct 14 ms 1876 KB Output is correct
5 Correct 19 ms 2316 KB Output is correct
6 Correct 12 ms 1592 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 11 ms 1620 KB Output is correct
9 Correct 27 ms 3736 KB Output is correct
10 Correct 15 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 8 ms 1164 KB Output is correct
17 Correct 23 ms 2972 KB Output is correct
18 Correct 29 ms 3336 KB Output is correct
19 Correct 65 ms 3092 KB Output is correct
20 Correct 73 ms 3424 KB Output is correct
21 Correct 22 ms 2808 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 16 ms 1652 KB Output is correct
24 Correct 26 ms 3148 KB Output is correct
25 Correct 4 ms 468 KB Output is correct
26 Correct 17 ms 2004 KB Output is correct
27 Correct 22 ms 2380 KB Output is correct
28 Correct 28 ms 3324 KB Output is correct
29 Correct 9 ms 1320 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2644 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 12 ms 1768 KB Output is correct
4 Correct 14 ms 1876 KB Output is correct
5 Correct 19 ms 2316 KB Output is correct
6 Correct 12 ms 1592 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 11 ms 1620 KB Output is correct
9 Correct 27 ms 3736 KB Output is correct
10 Correct 15 ms 2132 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 8 ms 1164 KB Output is correct
27 Correct 23 ms 2972 KB Output is correct
28 Correct 29 ms 3336 KB Output is correct
29 Correct 65 ms 3092 KB Output is correct
30 Correct 73 ms 3424 KB Output is correct
31 Correct 22 ms 2808 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 16 ms 1652 KB Output is correct
34 Correct 26 ms 3148 KB Output is correct
35 Correct 4 ms 468 KB Output is correct
36 Correct 17 ms 2004 KB Output is correct
37 Correct 22 ms 2380 KB Output is correct
38 Correct 28 ms 3324 KB Output is correct
39 Correct 9 ms 1320 KB Output is correct
40 Correct 1 ms 304 KB Output is correct
41 Correct 63 ms 3540 KB Output is correct
42 Correct 36 ms 3916 KB Output is correct
43 Correct 51 ms 3652 KB Output is correct
44 Correct 31 ms 3820 KB Output is correct
45 Correct 29 ms 4052 KB Output is correct
46 Correct 69 ms 3948 KB Output is correct
47 Correct 25 ms 3680 KB Output is correct
48 Correct 38 ms 3736 KB Output is correct
49 Correct 28 ms 3556 KB Output is correct
50 Correct 262 ms 3876 KB Output is correct
51 Correct 277 ms 4108 KB Output is correct
52 Correct 258 ms 3848 KB Output is correct
53 Correct 275 ms 4140 KB Output is correct
54 Correct 255 ms 3772 KB Output is correct
55 Correct 287 ms 4224 KB Output is correct
56 Correct 248 ms 3716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 264 KB Output is correct
5 Correct 1 ms 240 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 19 ms 2644 KB Output is correct
10 Correct 5 ms 852 KB Output is correct
11 Correct 12 ms 1768 KB Output is correct
12 Correct 14 ms 1876 KB Output is correct
13 Correct 19 ms 2316 KB Output is correct
14 Correct 12 ms 1592 KB Output is correct
15 Correct 3 ms 560 KB Output is correct
16 Correct 11 ms 1620 KB Output is correct
17 Correct 27 ms 3736 KB Output is correct
18 Correct 15 ms 2132 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 8 ms 1164 KB Output is correct
35 Correct 23 ms 2972 KB Output is correct
36 Correct 29 ms 3336 KB Output is correct
37 Correct 65 ms 3092 KB Output is correct
38 Correct 73 ms 3424 KB Output is correct
39 Correct 22 ms 2808 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 16 ms 1652 KB Output is correct
42 Correct 26 ms 3148 KB Output is correct
43 Correct 4 ms 468 KB Output is correct
44 Correct 17 ms 2004 KB Output is correct
45 Correct 22 ms 2380 KB Output is correct
46 Correct 28 ms 3324 KB Output is correct
47 Correct 9 ms 1320 KB Output is correct
48 Correct 1 ms 304 KB Output is correct
49 Correct 63 ms 3540 KB Output is correct
50 Correct 36 ms 3916 KB Output is correct
51 Correct 51 ms 3652 KB Output is correct
52 Correct 31 ms 3820 KB Output is correct
53 Correct 29 ms 4052 KB Output is correct
54 Correct 69 ms 3948 KB Output is correct
55 Correct 25 ms 3680 KB Output is correct
56 Correct 38 ms 3736 KB Output is correct
57 Correct 28 ms 3556 KB Output is correct
58 Correct 262 ms 3876 KB Output is correct
59 Correct 277 ms 4108 KB Output is correct
60 Correct 258 ms 3848 KB Output is correct
61 Correct 275 ms 4140 KB Output is correct
62 Correct 255 ms 3772 KB Output is correct
63 Correct 287 ms 4224 KB Output is correct
64 Correct 248 ms 3716 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 267 ms 3908 KB Output is correct
68 Correct 267 ms 3964 KB Output is correct
69 Correct 234 ms 3516 KB Output is correct
70 Correct 263 ms 3860 KB Output is correct
71 Correct 258 ms 3804 KB Output is correct
72 Correct 253 ms 3724 KB Output is correct
73 Correct 245 ms 3644 KB Output is correct
74 Correct 264 ms 3856 KB Output is correct
75 Correct 258 ms 3776 KB Output is correct
76 Correct 275 ms 4016 KB Output is correct
77 Correct 57 ms 4196 KB Output is correct
78 Correct 31 ms 3788 KB Output is correct
79 Correct 43 ms 3620 KB Output is correct
80 Correct 44 ms 3748 KB Output is correct
81 Correct 48 ms 3520 KB Output is correct
82 Correct 48 ms 3916 KB Output is correct
83 Correct 33 ms 3616 KB Output is correct
84 Correct 168 ms 4108 KB Output is correct
85 Correct 290 ms 4164 KB Output is correct
86 Correct 1 ms 212 KB Output is correct
87 Correct 1 ms 212 KB Output is correct
88 Correct 287 ms 4228 KB Output is correct
89 Correct 58 ms 928 KB Output is correct
90 Correct 1 ms 212 KB Output is correct