# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289653 | 2020-09-02T21:22:04 Z | luciocf | Chessboard (IZhO18_chessboard) | C++14 | 272 ms | 1144 KB |
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; typedef pair<int, int> pii; typedef long long ll; const int maxn = 1e5+10; const ll inf = 1e18+10; pii pt[maxn]; int main(void) { int n, k; scanf("%d %d", &n, &k); for (int i = 1; i <= k; i++) { scanf("%d %d", &pt[i].ff, &pt[i].ss); scanf("%d %d", &pt[i].ff, &pt[i].ss); pt[i].ff--, pt[i].ss--; } vector<int> D; for (int d = 1; d*d <= n; d++) { if (n%d) continue; D.push_back(d); if (n/d != d) D.push_back(n/d); } ll ans = inf; for (auto d: D) { if (d == n) continue; int p = 0, b = 0; for (int i = 1; i <= k; i++) { int ma = pt[i].ff%(2*d); int mb = pt[i].ss%(2*d); if ((ma < d && mb < d) || (ma >= d && mb >= d)) p++; else b++; } ll x = ((n+2*d-1)/(2*d)); ll y = n/(2*d); ll tot_p = 1ll*d*d*(x*x+y*y); ans = min(ans, (tot_p-p)+b); swap(p, b); tot_p = 1ll*n*n-tot_p; ans = min(ans, (tot_p-p)+b); } printf("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 900 KB | Output is correct |
2 | Correct | 9 ms | 384 KB | Output is correct |
3 | Correct | 23 ms | 640 KB | Output is correct |
4 | Correct | 24 ms | 888 KB | Output is correct |
5 | Correct | 31 ms | 760 KB | Output is correct |
6 | Correct | 20 ms | 632 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 20 ms | 640 KB | Output is correct |
9 | Correct | 53 ms | 1016 KB | Output is correct |
10 | Correct | 28 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 14 ms | 512 KB | Output is correct |
17 | Correct | 42 ms | 1016 KB | Output is correct |
18 | Correct | 51 ms | 1016 KB | Output is correct |
19 | Correct | 80 ms | 1016 KB | Output is correct |
20 | Correct | 91 ms | 1016 KB | Output is correct |
21 | Correct | 39 ms | 888 KB | Output is correct |
22 | Correct | 1 ms | 256 KB | Output is correct |
23 | Correct | 25 ms | 640 KB | Output is correct |
24 | Correct | 46 ms | 1036 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 29 ms | 768 KB | Output is correct |
27 | Correct | 41 ms | 896 KB | Output is correct |
28 | Correct | 51 ms | 1016 KB | Output is correct |
29 | Correct | 16 ms | 512 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 900 KB | Output is correct |
2 | Correct | 9 ms | 384 KB | Output is correct |
3 | Correct | 23 ms | 640 KB | Output is correct |
4 | Correct | 24 ms | 888 KB | Output is correct |
5 | Correct | 31 ms | 760 KB | Output is correct |
6 | Correct | 20 ms | 632 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 20 ms | 640 KB | Output is correct |
9 | Correct | 53 ms | 1016 KB | Output is correct |
10 | Correct | 28 ms | 640 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 256 KB | Output is correct |
17 | Correct | 1 ms | 256 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 256 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 256 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 14 ms | 512 KB | Output is correct |
27 | Correct | 42 ms | 1016 KB | Output is correct |
28 | Correct | 51 ms | 1016 KB | Output is correct |
29 | Correct | 80 ms | 1016 KB | Output is correct |
30 | Correct | 91 ms | 1016 KB | Output is correct |
31 | Correct | 39 ms | 888 KB | Output is correct |
32 | Correct | 1 ms | 256 KB | Output is correct |
33 | Correct | 25 ms | 640 KB | Output is correct |
34 | Correct | 46 ms | 1036 KB | Output is correct |
35 | Correct | 5 ms | 384 KB | Output is correct |
36 | Correct | 29 ms | 768 KB | Output is correct |
37 | Correct | 41 ms | 896 KB | Output is correct |
38 | Correct | 51 ms | 1016 KB | Output is correct |
39 | Correct | 16 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 78 ms | 1016 KB | Output is correct |
42 | Correct | 57 ms | 1052 KB | Output is correct |
43 | Correct | 62 ms | 1016 KB | Output is correct |
44 | Correct | 55 ms | 1060 KB | Output is correct |
45 | Correct | 56 ms | 1016 KB | Output is correct |
46 | Correct | 89 ms | 1016 KB | Output is correct |
47 | Correct | 49 ms | 1016 KB | Output is correct |
48 | Correct | 60 ms | 1016 KB | Output is correct |
49 | Correct | 50 ms | 1016 KB | Output is correct |
50 | Correct | 246 ms | 1016 KB | Output is correct |
51 | Correct | 263 ms | 1016 KB | Output is correct |
52 | Correct | 246 ms | 1060 KB | Output is correct |
53 | Correct | 262 ms | 1144 KB | Output is correct |
54 | Correct | 244 ms | 1016 KB | Output is correct |
55 | Correct | 272 ms | 1144 KB | Output is correct |
56 | Correct | 232 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 35 ms | 900 KB | Output is correct |
10 | Correct | 9 ms | 384 KB | Output is correct |
11 | Correct | 23 ms | 640 KB | Output is correct |
12 | Correct | 24 ms | 888 KB | Output is correct |
13 | Correct | 31 ms | 760 KB | Output is correct |
14 | Correct | 20 ms | 632 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 20 ms | 640 KB | Output is correct |
17 | Correct | 53 ms | 1016 KB | Output is correct |
18 | Correct | 28 ms | 640 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 0 ms | 256 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 256 KB | Output is correct |
25 | Correct | 1 ms | 256 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 256 KB | Output is correct |
28 | Correct | 1 ms | 256 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 256 KB | Output is correct |
31 | Correct | 1 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 256 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 14 ms | 512 KB | Output is correct |
35 | Correct | 42 ms | 1016 KB | Output is correct |
36 | Correct | 51 ms | 1016 KB | Output is correct |
37 | Correct | 80 ms | 1016 KB | Output is correct |
38 | Correct | 91 ms | 1016 KB | Output is correct |
39 | Correct | 39 ms | 888 KB | Output is correct |
40 | Correct | 1 ms | 256 KB | Output is correct |
41 | Correct | 25 ms | 640 KB | Output is correct |
42 | Correct | 46 ms | 1036 KB | Output is correct |
43 | Correct | 5 ms | 384 KB | Output is correct |
44 | Correct | 29 ms | 768 KB | Output is correct |
45 | Correct | 41 ms | 896 KB | Output is correct |
46 | Correct | 51 ms | 1016 KB | Output is correct |
47 | Correct | 16 ms | 512 KB | Output is correct |
48 | Correct | 2 ms | 384 KB | Output is correct |
49 | Correct | 78 ms | 1016 KB | Output is correct |
50 | Correct | 57 ms | 1052 KB | Output is correct |
51 | Correct | 62 ms | 1016 KB | Output is correct |
52 | Correct | 55 ms | 1060 KB | Output is correct |
53 | Correct | 56 ms | 1016 KB | Output is correct |
54 | Correct | 89 ms | 1016 KB | Output is correct |
55 | Correct | 49 ms | 1016 KB | Output is correct |
56 | Correct | 60 ms | 1016 KB | Output is correct |
57 | Correct | 50 ms | 1016 KB | Output is correct |
58 | Correct | 246 ms | 1016 KB | Output is correct |
59 | Correct | 263 ms | 1016 KB | Output is correct |
60 | Correct | 246 ms | 1060 KB | Output is correct |
61 | Correct | 262 ms | 1144 KB | Output is correct |
62 | Correct | 244 ms | 1016 KB | Output is correct |
63 | Correct | 272 ms | 1144 KB | Output is correct |
64 | Correct | 232 ms | 1016 KB | Output is correct |
65 | Correct | 0 ms | 256 KB | Output is correct |
66 | Incorrect | 0 ms | 256 KB | Output isn't correct |
67 | Halted | 0 ms | 0 KB | - |