Submission #50844

# Submission time Handle Problem Language Result Execution time Memory
50844 2018-06-13T16:34:08 Z Nicksechko Chessboard (IZhO18_chessboard) C++14
70 / 100
590 ms 1532 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]
  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]
   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]
   scanf("%d%d", x + i, y + i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 472 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 3 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 980 KB Output is correct
2 Correct 11 ms 980 KB Output is correct
3 Correct 25 ms 980 KB Output is correct
4 Correct 31 ms 1004 KB Output is correct
5 Correct 61 ms 1004 KB Output is correct
6 Correct 20 ms 1004 KB Output is correct
7 Correct 6 ms 1004 KB Output is correct
8 Correct 23 ms 1004 KB Output is correct
9 Correct 84 ms 1260 KB Output is correct
10 Correct 36 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1260 KB Output is correct
2 Correct 3 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 3 ms 1260 KB Output is correct
6 Correct 2 ms 1260 KB Output is correct
7 Correct 3 ms 1260 KB Output is correct
8 Correct 2 ms 1260 KB Output is correct
9 Correct 6 ms 1260 KB Output is correct
10 Correct 2 ms 1260 KB Output is correct
11 Correct 3 ms 1260 KB Output is correct
12 Correct 3 ms 1260 KB Output is correct
13 Correct 3 ms 1260 KB Output is correct
14 Correct 3 ms 1260 KB Output is correct
15 Correct 2 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1260 KB Output is correct
2 Correct 3 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 3 ms 1260 KB Output is correct
6 Correct 2 ms 1260 KB Output is correct
7 Correct 3 ms 1260 KB Output is correct
8 Correct 2 ms 1260 KB Output is correct
9 Correct 6 ms 1260 KB Output is correct
10 Correct 2 ms 1260 KB Output is correct
11 Correct 3 ms 1260 KB Output is correct
12 Correct 3 ms 1260 KB Output is correct
13 Correct 3 ms 1260 KB Output is correct
14 Correct 3 ms 1260 KB Output is correct
15 Correct 2 ms 1260 KB Output is correct
16 Correct 19 ms 1260 KB Output is correct
17 Correct 42 ms 1260 KB Output is correct
18 Correct 67 ms 1388 KB Output is correct
19 Correct 191 ms 1388 KB Output is correct
20 Correct 151 ms 1388 KB Output is correct
21 Correct 61 ms 1388 KB Output is correct
22 Correct 3 ms 1388 KB Output is correct
23 Correct 32 ms 1388 KB Output is correct
24 Correct 51 ms 1388 KB Output is correct
25 Correct 11 ms 1388 KB Output is correct
26 Correct 49 ms 1388 KB Output is correct
27 Correct 63 ms 1388 KB Output is correct
28 Correct 58 ms 1388 KB Output is correct
29 Correct 24 ms 1388 KB Output is correct
30 Correct 3 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 980 KB Output is correct
2 Correct 11 ms 980 KB Output is correct
3 Correct 25 ms 980 KB Output is correct
4 Correct 31 ms 1004 KB Output is correct
5 Correct 61 ms 1004 KB Output is correct
6 Correct 20 ms 1004 KB Output is correct
7 Correct 6 ms 1004 KB Output is correct
8 Correct 23 ms 1004 KB Output is correct
9 Correct 84 ms 1260 KB Output is correct
10 Correct 36 ms 1260 KB Output is correct
11 Correct 3 ms 1260 KB Output is correct
12 Correct 3 ms 1260 KB Output is correct
13 Correct 2 ms 1260 KB Output is correct
14 Correct 3 ms 1260 KB Output is correct
15 Correct 3 ms 1260 KB Output is correct
16 Correct 2 ms 1260 KB Output is correct
17 Correct 3 ms 1260 KB Output is correct
18 Correct 2 ms 1260 KB Output is correct
19 Correct 6 ms 1260 KB Output is correct
20 Correct 2 ms 1260 KB Output is correct
21 Correct 3 ms 1260 KB Output is correct
22 Correct 3 ms 1260 KB Output is correct
23 Correct 3 ms 1260 KB Output is correct
24 Correct 3 ms 1260 KB Output is correct
25 Correct 2 ms 1260 KB Output is correct
26 Correct 19 ms 1260 KB Output is correct
27 Correct 42 ms 1260 KB Output is correct
28 Correct 67 ms 1388 KB Output is correct
29 Correct 191 ms 1388 KB Output is correct
30 Correct 151 ms 1388 KB Output is correct
31 Correct 61 ms 1388 KB Output is correct
32 Correct 3 ms 1388 KB Output is correct
33 Correct 32 ms 1388 KB Output is correct
34 Correct 51 ms 1388 KB Output is correct
35 Correct 11 ms 1388 KB Output is correct
36 Correct 49 ms 1388 KB Output is correct
37 Correct 63 ms 1388 KB Output is correct
38 Correct 58 ms 1388 KB Output is correct
39 Correct 24 ms 1388 KB Output is correct
40 Correct 3 ms 1388 KB Output is correct
41 Correct 116 ms 1388 KB Output is correct
42 Correct 63 ms 1388 KB Output is correct
43 Correct 82 ms 1388 KB Output is correct
44 Correct 84 ms 1388 KB Output is correct
45 Correct 63 ms 1388 KB Output is correct
46 Correct 163 ms 1392 KB Output is correct
47 Correct 57 ms 1392 KB Output is correct
48 Correct 82 ms 1392 KB Output is correct
49 Correct 56 ms 1392 KB Output is correct
50 Correct 496 ms 1392 KB Output is correct
51 Correct 498 ms 1532 KB Output is correct
52 Correct 502 ms 1532 KB Output is correct
53 Correct 568 ms 1532 KB Output is correct
54 Correct 498 ms 1532 KB Output is correct
55 Correct 590 ms 1532 KB Output is correct
56 Correct 537 ms 1532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 472 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 3 ms 552 KB Output is correct
9 Correct 41 ms 980 KB Output is correct
10 Correct 11 ms 980 KB Output is correct
11 Correct 25 ms 980 KB Output is correct
12 Correct 31 ms 1004 KB Output is correct
13 Correct 61 ms 1004 KB Output is correct
14 Correct 20 ms 1004 KB Output is correct
15 Correct 6 ms 1004 KB Output is correct
16 Correct 23 ms 1004 KB Output is correct
17 Correct 84 ms 1260 KB Output is correct
18 Correct 36 ms 1260 KB Output is correct
19 Correct 3 ms 1260 KB Output is correct
20 Correct 3 ms 1260 KB Output is correct
21 Correct 2 ms 1260 KB Output is correct
22 Correct 3 ms 1260 KB Output is correct
23 Correct 3 ms 1260 KB Output is correct
24 Correct 2 ms 1260 KB Output is correct
25 Correct 3 ms 1260 KB Output is correct
26 Correct 2 ms 1260 KB Output is correct
27 Correct 6 ms 1260 KB Output is correct
28 Correct 2 ms 1260 KB Output is correct
29 Correct 3 ms 1260 KB Output is correct
30 Correct 3 ms 1260 KB Output is correct
31 Correct 3 ms 1260 KB Output is correct
32 Correct 3 ms 1260 KB Output is correct
33 Correct 2 ms 1260 KB Output is correct
34 Correct 19 ms 1260 KB Output is correct
35 Correct 42 ms 1260 KB Output is correct
36 Correct 67 ms 1388 KB Output is correct
37 Correct 191 ms 1388 KB Output is correct
38 Correct 151 ms 1388 KB Output is correct
39 Correct 61 ms 1388 KB Output is correct
40 Correct 3 ms 1388 KB Output is correct
41 Correct 32 ms 1388 KB Output is correct
42 Correct 51 ms 1388 KB Output is correct
43 Correct 11 ms 1388 KB Output is correct
44 Correct 49 ms 1388 KB Output is correct
45 Correct 63 ms 1388 KB Output is correct
46 Correct 58 ms 1388 KB Output is correct
47 Correct 24 ms 1388 KB Output is correct
48 Correct 3 ms 1388 KB Output is correct
49 Correct 116 ms 1388 KB Output is correct
50 Correct 63 ms 1388 KB Output is correct
51 Correct 82 ms 1388 KB Output is correct
52 Correct 84 ms 1388 KB Output is correct
53 Correct 63 ms 1388 KB Output is correct
54 Correct 163 ms 1392 KB Output is correct
55 Correct 57 ms 1392 KB Output is correct
56 Correct 82 ms 1392 KB Output is correct
57 Correct 56 ms 1392 KB Output is correct
58 Correct 496 ms 1392 KB Output is correct
59 Correct 498 ms 1532 KB Output is correct
60 Correct 502 ms 1532 KB Output is correct
61 Correct 568 ms 1532 KB Output is correct
62 Correct 498 ms 1532 KB Output is correct
63 Correct 590 ms 1532 KB Output is correct
64 Correct 537 ms 1532 KB Output is correct
65 Correct 2 ms 1532 KB Output is correct
66 Incorrect 2 ms 1532 KB Output isn't correct
67 Halted 0 ms 0 KB -