답안 #872768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872768 2023-11-13T17:34:31 Z epicci23 Chessboard (IZhO18_chessboard) C++17
70 / 100
208 ms 3496 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e5 + 256;

long long n, k;
int x[MAXN], y[MAXN];
long long res;

inline void f(long long len) {
	long long cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < k; ++i) {
		if ((x[i] / len % 2) == (y[i] / len % 2)) {
			++cnt1;
		} else {
			++cnt2;
		}
	}
	long long e;
	e = ((n/len*n/len + 1) / 2);
	res = min(res, cnt2 + len * len * e - cnt1);
	e = (n/len*n/len) - e;
	res = min(res, cnt1 + len * len * e - cnt2);
} 

int main() {
	scanf("%lld%lld", &n, &k);
	res = n * n;
	
	for (int i = 0; i < k; ++i) {
		scanf("%d%d", x + i, y + i);
		scanf("%d%d", x + i, y + i);
		--x[i];
		--y[i];
	}

	for (int len = 1; len * len <= n; ++len) {
		if (n % len == 0) {
			f(len);
			if (n / len != n) f(n / len);
		}
	}
	
	printf("%lld\n", res);
	
	return 0;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%lld%lld", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~
chessboard.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   scanf("%d%d", x + i, y + i);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
chessboard.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d%d", x + i, y + i);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2392 KB Output is correct
2 Correct 6 ms 1112 KB Output is correct
3 Correct 12 ms 1628 KB Output is correct
4 Correct 13 ms 1628 KB Output is correct
5 Correct 16 ms 1988 KB Output is correct
6 Correct 13 ms 1372 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 10 ms 1364 KB Output is correct
9 Correct 27 ms 3164 KB Output is correct
10 Correct 14 ms 1852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 8 ms 860 KB Output is correct
17 Correct 22 ms 2352 KB Output is correct
18 Correct 28 ms 2900 KB Output is correct
19 Correct 53 ms 2396 KB Output is correct
20 Correct 60 ms 2728 KB Output is correct
21 Correct 21 ms 2128 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 15 ms 1372 KB Output is correct
24 Correct 32 ms 2396 KB Output is correct
25 Correct 3 ms 600 KB Output is correct
26 Correct 19 ms 1628 KB Output is correct
27 Correct 21 ms 1884 KB Output is correct
28 Correct 27 ms 2708 KB Output is correct
29 Correct 9 ms 1112 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2392 KB Output is correct
2 Correct 6 ms 1112 KB Output is correct
3 Correct 12 ms 1628 KB Output is correct
4 Correct 13 ms 1628 KB Output is correct
5 Correct 16 ms 1988 KB Output is correct
6 Correct 13 ms 1372 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 10 ms 1364 KB Output is correct
9 Correct 27 ms 3164 KB Output is correct
10 Correct 14 ms 1852 KB Output is correct
11 Correct 1 ms 348 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 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 8 ms 860 KB Output is correct
27 Correct 22 ms 2352 KB Output is correct
28 Correct 28 ms 2900 KB Output is correct
29 Correct 53 ms 2396 KB Output is correct
30 Correct 60 ms 2728 KB Output is correct
31 Correct 21 ms 2128 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 15 ms 1372 KB Output is correct
34 Correct 32 ms 2396 KB Output is correct
35 Correct 3 ms 600 KB Output is correct
36 Correct 19 ms 1628 KB Output is correct
37 Correct 21 ms 1884 KB Output is correct
38 Correct 27 ms 2708 KB Output is correct
39 Correct 9 ms 1112 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 50 ms 3008 KB Output is correct
42 Correct 39 ms 3412 KB Output is correct
43 Correct 36 ms 2900 KB Output is correct
44 Correct 28 ms 3164 KB Output is correct
45 Correct 29 ms 3408 KB Output is correct
46 Correct 56 ms 3376 KB Output is correct
47 Correct 24 ms 3164 KB Output is correct
48 Correct 32 ms 3096 KB Output is correct
49 Correct 27 ms 2908 KB Output is correct
50 Correct 188 ms 3300 KB Output is correct
51 Correct 200 ms 3496 KB Output is correct
52 Correct 191 ms 3284 KB Output is correct
53 Correct 201 ms 3472 KB Output is correct
54 Correct 184 ms 3164 KB Output is correct
55 Correct 208 ms 3420 KB Output is correct
56 Correct 179 ms 3156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 18 ms 2392 KB Output is correct
10 Correct 6 ms 1112 KB Output is correct
11 Correct 12 ms 1628 KB Output is correct
12 Correct 13 ms 1628 KB Output is correct
13 Correct 16 ms 1988 KB Output is correct
14 Correct 13 ms 1372 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 10 ms 1364 KB Output is correct
17 Correct 27 ms 3164 KB Output is correct
18 Correct 14 ms 1852 KB Output is correct
19 Correct 1 ms 348 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 0 ms 348 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 8 ms 860 KB Output is correct
35 Correct 22 ms 2352 KB Output is correct
36 Correct 28 ms 2900 KB Output is correct
37 Correct 53 ms 2396 KB Output is correct
38 Correct 60 ms 2728 KB Output is correct
39 Correct 21 ms 2128 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 15 ms 1372 KB Output is correct
42 Correct 32 ms 2396 KB Output is correct
43 Correct 3 ms 600 KB Output is correct
44 Correct 19 ms 1628 KB Output is correct
45 Correct 21 ms 1884 KB Output is correct
46 Correct 27 ms 2708 KB Output is correct
47 Correct 9 ms 1112 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 50 ms 3008 KB Output is correct
50 Correct 39 ms 3412 KB Output is correct
51 Correct 36 ms 2900 KB Output is correct
52 Correct 28 ms 3164 KB Output is correct
53 Correct 29 ms 3408 KB Output is correct
54 Correct 56 ms 3376 KB Output is correct
55 Correct 24 ms 3164 KB Output is correct
56 Correct 32 ms 3096 KB Output is correct
57 Correct 27 ms 2908 KB Output is correct
58 Correct 188 ms 3300 KB Output is correct
59 Correct 200 ms 3496 KB Output is correct
60 Correct 191 ms 3284 KB Output is correct
61 Correct 201 ms 3472 KB Output is correct
62 Correct 184 ms 3164 KB Output is correct
63 Correct 208 ms 3420 KB Output is correct
64 Correct 179 ms 3156 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Incorrect 0 ms 348 KB Output isn't correct
67 Halted 0 ms 0 KB -