# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99771 | 2019-03-07T02:54:35 Z | choikiwon | Chessboard (IZhO18_chessboard) | C++17 | 693 ms | 4344 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MN = 100010; int N, K; struct Rect { int r1, c1, r2, c2; }; Rect rect[MN]; int main() { scanf("%d %d", &N, &K); for(int i = 0; i < K; i++) { scanf("%d %d %d %d", &rect[i].r1, &rect[i].c1, &rect[i].r2, &rect[i].c2); rect[i].r1--; rect[i].c1--; rect[i].r2--; rect[i].c2--; } ll mn = 1e18; for(int i = 1; i < N; i++) { if(N % i == 0) { for(int j = 0; j < 2; j++) { int n = N / i; ll tmp = j? (1LL * n * n + 1) / 2 : 1LL * n * n / 2; tmp *= 1LL * i * i; for(int k = 0; k < K; k++) { int rr = min(rect[k].r2 + 1, (rect[k].r1 + i) / i * i); int cc = min(rect[k].c2 + 1, (rect[k].c1 + i) / i * i); int br = (rect[k].r2 - rr + 1) / (2 * i); int bc = (rect[k].c2 - cc + 1) / (2 * i); if((rect[k].r2 - rr + 1) % (2 * i) > i) br += (rect[k].r2 - rr + 1) % (2 * i) - i; if((rect[k].c2 - cc + 1) % (2 * i) > i) bc += (rect[k].c2 - cc + 1) % (2 * i) - i; br += rr - rect[k].r1; bc += cc - rect[k].c1; int wr = rect[k].r2 - rect[k].r1 + 1 - br; int wc = rect[k].c2 - rect[k].c1 + 1 - bc; if(j ^ ((rect[k].r1 / i + rect[k].c1 / i) & 1)) tmp -= 1LL * (br - wr) * (bc - wc); else tmp += 1LL * (br - wr) * (bc - wc); } mn = min(mn, tmp); } } } printf("%lld", mn); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 1272 KB | Output is correct |
2 | Correct | 9 ms | 512 KB | Output is correct |
3 | Correct | 21 ms | 896 KB | Output is correct |
4 | Correct | 23 ms | 1016 KB | Output is correct |
5 | Correct | 33 ms | 1152 KB | Output is correct |
6 | Correct | 31 ms | 844 KB | Output is correct |
7 | Correct | 9 ms | 512 KB | Output is correct |
8 | Correct | 20 ms | 896 KB | Output is correct |
9 | Correct | 53 ms | 1656 KB | Output is correct |
10 | Correct | 25 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 18 ms | 768 KB | Output is correct |
17 | Correct | 36 ms | 1656 KB | Output is correct |
18 | Correct | 51 ms | 1912 KB | Output is correct |
19 | Correct | 167 ms | 1748 KB | Output is correct |
20 | Correct | 167 ms | 1912 KB | Output is correct |
21 | Correct | 34 ms | 1656 KB | Output is correct |
22 | Correct | 3 ms | 256 KB | Output is correct |
23 | Correct | 53 ms | 1016 KB | Output is correct |
24 | Correct | 54 ms | 1784 KB | Output is correct |
25 | Correct | 8 ms | 384 KB | Output is correct |
26 | Correct | 47 ms | 1276 KB | Output is correct |
27 | Correct | 45 ms | 1380 KB | Output is correct |
28 | Correct | 53 ms | 1780 KB | Output is correct |
29 | Correct | 17 ms | 896 KB | Output is correct |
30 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 1272 KB | Output is correct |
2 | Correct | 9 ms | 512 KB | Output is correct |
3 | Correct | 21 ms | 896 KB | Output is correct |
4 | Correct | 23 ms | 1016 KB | Output is correct |
5 | Correct | 33 ms | 1152 KB | Output is correct |
6 | Correct | 31 ms | 844 KB | Output is correct |
7 | Correct | 9 ms | 512 KB | Output is correct |
8 | Correct | 20 ms | 896 KB | Output is correct |
9 | Correct | 53 ms | 1656 KB | Output is correct |
10 | Correct | 25 ms | 1144 KB | Output is correct |
11 | Correct | 3 ms | 256 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 256 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 18 ms | 768 KB | Output is correct |
27 | Correct | 36 ms | 1656 KB | Output is correct |
28 | Correct | 51 ms | 1912 KB | Output is correct |
29 | Correct | 167 ms | 1748 KB | Output is correct |
30 | Correct | 167 ms | 1912 KB | Output is correct |
31 | Correct | 34 ms | 1656 KB | Output is correct |
32 | Correct | 3 ms | 256 KB | Output is correct |
33 | Correct | 53 ms | 1016 KB | Output is correct |
34 | Correct | 54 ms | 1784 KB | Output is correct |
35 | Correct | 8 ms | 384 KB | Output is correct |
36 | Correct | 47 ms | 1276 KB | Output is correct |
37 | Correct | 45 ms | 1380 KB | Output is correct |
38 | Correct | 53 ms | 1780 KB | Output is correct |
39 | Correct | 17 ms | 896 KB | Output is correct |
40 | Correct | 4 ms | 384 KB | Output is correct |
41 | Correct | 135 ms | 1656 KB | Output is correct |
42 | Correct | 58 ms | 4008 KB | Output is correct |
43 | Correct | 88 ms | 3576 KB | Output is correct |
44 | Correct | 59 ms | 3960 KB | Output is correct |
45 | Correct | 93 ms | 4216 KB | Output is correct |
46 | Correct | 153 ms | 4052 KB | Output is correct |
47 | Correct | 60 ms | 3708 KB | Output is correct |
48 | Correct | 78 ms | 3832 KB | Output is correct |
49 | Correct | 78 ms | 3704 KB | Output is correct |
50 | Correct | 619 ms | 4016 KB | Output is correct |
51 | Correct | 641 ms | 4216 KB | Output is correct |
52 | Correct | 643 ms | 3960 KB | Output is correct |
53 | Correct | 663 ms | 4216 KB | Output is correct |
54 | Correct | 589 ms | 3840 KB | Output is correct |
55 | Correct | 669 ms | 4344 KB | Output is correct |
56 | Correct | 574 ms | 3832 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 33 ms | 1272 KB | Output is correct |
10 | Correct | 9 ms | 512 KB | Output is correct |
11 | Correct | 21 ms | 896 KB | Output is correct |
12 | Correct | 23 ms | 1016 KB | Output is correct |
13 | Correct | 33 ms | 1152 KB | Output is correct |
14 | Correct | 31 ms | 844 KB | Output is correct |
15 | Correct | 9 ms | 512 KB | Output is correct |
16 | Correct | 20 ms | 896 KB | Output is correct |
17 | Correct | 53 ms | 1656 KB | Output is correct |
18 | Correct | 25 ms | 1144 KB | Output is correct |
19 | Correct | 3 ms | 256 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 256 KB | Output is correct |
28 | Correct | 2 ms | 256 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 3 ms | 384 KB | Output is correct |
33 | Correct | 3 ms | 384 KB | Output is correct |
34 | Correct | 18 ms | 768 KB | Output is correct |
35 | Correct | 36 ms | 1656 KB | Output is correct |
36 | Correct | 51 ms | 1912 KB | Output is correct |
37 | Correct | 167 ms | 1748 KB | Output is correct |
38 | Correct | 167 ms | 1912 KB | Output is correct |
39 | Correct | 34 ms | 1656 KB | Output is correct |
40 | Correct | 3 ms | 256 KB | Output is correct |
41 | Correct | 53 ms | 1016 KB | Output is correct |
42 | Correct | 54 ms | 1784 KB | Output is correct |
43 | Correct | 8 ms | 384 KB | Output is correct |
44 | Correct | 47 ms | 1276 KB | Output is correct |
45 | Correct | 45 ms | 1380 KB | Output is correct |
46 | Correct | 53 ms | 1780 KB | Output is correct |
47 | Correct | 17 ms | 896 KB | Output is correct |
48 | Correct | 4 ms | 384 KB | Output is correct |
49 | Correct | 135 ms | 1656 KB | Output is correct |
50 | Correct | 58 ms | 4008 KB | Output is correct |
51 | Correct | 88 ms | 3576 KB | Output is correct |
52 | Correct | 59 ms | 3960 KB | Output is correct |
53 | Correct | 93 ms | 4216 KB | Output is correct |
54 | Correct | 153 ms | 4052 KB | Output is correct |
55 | Correct | 60 ms | 3708 KB | Output is correct |
56 | Correct | 78 ms | 3832 KB | Output is correct |
57 | Correct | 78 ms | 3704 KB | Output is correct |
58 | Correct | 619 ms | 4016 KB | Output is correct |
59 | Correct | 641 ms | 4216 KB | Output is correct |
60 | Correct | 643 ms | 3960 KB | Output is correct |
61 | Correct | 663 ms | 4216 KB | Output is correct |
62 | Correct | 589 ms | 3840 KB | Output is correct |
63 | Correct | 669 ms | 4344 KB | Output is correct |
64 | Correct | 574 ms | 3832 KB | Output is correct |
65 | Correct | 3 ms | 512 KB | Output is correct |
66 | Correct | 3 ms | 256 KB | Output is correct |
67 | Incorrect | 693 ms | 4076 KB | Output isn't correct |
68 | Halted | 0 ms | 0 KB | - |