# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
76739 | 2018-09-17T06:09:32 Z | Good | Chessboard (IZhO18_chessboard) | C++11 | 2000 ms | 63724 KB |
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define ff first #define ss second #define Maxn 100009 #define ll long long #define pb push_back #define Inf 1000000009 #define ppb() pop_back() #define pii pair <int , int> #define mid(x, y) (x + y) / 2 #define all(x) x.begin(),x.end() #define llInf 1000000000000000009 #define tr(i, c) for(__typeof(c).begin() i = (c).begin() ; i != (c).end() ; i++) using namespace std; using namespace __gnu_pbds; typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> order; int n, k; pii x[Maxn]; pii y[Maxn]; ll ans = llInf; vector <int> A; int main () { //freopen ("file.in", "r", stdin); //freopen ("file.out", "w", stdout); //srand ((unsigned) time ( NULL )); //int randomNumber = rand() % 10 + 1; scanf ("%d%d", &n, &k); for (int i = 1; i <= k; i++) scanf ("%d%d%d%d", &x[i].ff, &y[i].ff, &x[i].ss, &y[i].ss); for (int i = 1; i < n; i++) if (!(n % i)) A.pb (i); if (k == 0) { for (auto i: A) { ll v = i; ll u = n / i; u = ((u * u) / 2) * v * v; ans = min (ans, u); } return printf ("%lld\n", ans), 0; } for (int i = 0; i < 2; i++) { for (auto j: A) { ll v = j; ll u = n / j; if (i) u = ((u * u) / 2) * v * v; else u = ((u * u) - (u * u) / 2) * v * v; for (int l = 1; l <= k; l++) { for (int p = x[l].ff; p <= x[l].ss; p++) for (int e = y[l].ff; e <= y[l].ss; e++) { int a = (p - 1) / j; int b = (e - 1) / j; bool q = 0; if (!(a & 1) and b & 1) q = 1; if (a & 1 and !(b & 1)) q = 1; if (i) q = !q; if (q) u++; else u --; } } ans = min (ans, u); } } printf ("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 592 KB | Output is correct |
4 | Correct | 3 ms | 600 KB | Output is correct |
5 | Correct | 2 ms | 600 KB | Output is correct |
6 | Correct | 2 ms | 600 KB | Output is correct |
7 | Correct | 3 ms | 684 KB | Output is correct |
8 | Correct | 2 ms | 684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 3136 KB | Output is correct |
2 | Correct | 11 ms | 3136 KB | Output is correct |
3 | Correct | 28 ms | 4112 KB | Output is correct |
4 | Correct | 26 ms | 5052 KB | Output is correct |
5 | Correct | 32 ms | 6512 KB | Output is correct |
6 | Correct | 22 ms | 6908 KB | Output is correct |
7 | Correct | 6 ms | 6908 KB | Output is correct |
8 | Correct | 23 ms | 8056 KB | Output is correct |
9 | Correct | 68 ms | 10972 KB | Output is correct |
10 | Correct | 30 ms | 11516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 11516 KB | Output is correct |
2 | Correct | 2 ms | 11516 KB | Output is correct |
3 | Correct | 2 ms | 11516 KB | Output is correct |
4 | Correct | 3 ms | 11516 KB | Output is correct |
5 | Correct | 2 ms | 11516 KB | Output is correct |
6 | Correct | 3 ms | 11516 KB | Output is correct |
7 | Correct | 3 ms | 11516 KB | Output is correct |
8 | Correct | 2 ms | 11516 KB | Output is correct |
9 | Correct | 2 ms | 11516 KB | Output is correct |
10 | Correct | 2 ms | 11516 KB | Output is correct |
11 | Correct | 2 ms | 11516 KB | Output is correct |
12 | Correct | 2 ms | 11516 KB | Output is correct |
13 | Correct | 3 ms | 11516 KB | Output is correct |
14 | Correct | 3 ms | 11516 KB | Output is correct |
15 | Correct | 2 ms | 11516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 11516 KB | Output is correct |
2 | Correct | 2 ms | 11516 KB | Output is correct |
3 | Correct | 2 ms | 11516 KB | Output is correct |
4 | Correct | 3 ms | 11516 KB | Output is correct |
5 | Correct | 2 ms | 11516 KB | Output is correct |
6 | Correct | 3 ms | 11516 KB | Output is correct |
7 | Correct | 3 ms | 11516 KB | Output is correct |
8 | Correct | 2 ms | 11516 KB | Output is correct |
9 | Correct | 2 ms | 11516 KB | Output is correct |
10 | Correct | 2 ms | 11516 KB | Output is correct |
11 | Correct | 2 ms | 11516 KB | Output is correct |
12 | Correct | 2 ms | 11516 KB | Output is correct |
13 | Correct | 3 ms | 11516 KB | Output is correct |
14 | Correct | 3 ms | 11516 KB | Output is correct |
15 | Correct | 2 ms | 11516 KB | Output is correct |
16 | Correct | 19 ms | 11744 KB | Output is correct |
17 | Correct | 46 ms | 13984 KB | Output is correct |
18 | Correct | 59 ms | 15856 KB | Output is correct |
19 | Correct | 151 ms | 17184 KB | Output is correct |
20 | Correct | 172 ms | 18888 KB | Output is correct |
21 | Correct | 41 ms | 19952 KB | Output is correct |
22 | Correct | 2 ms | 19952 KB | Output is correct |
23 | Correct | 35 ms | 20008 KB | Output is correct |
24 | Correct | 52 ms | 22184 KB | Output is correct |
25 | Correct | 9 ms | 22184 KB | Output is correct |
26 | Correct | 35 ms | 22824 KB | Output is correct |
27 | Correct | 50 ms | 23996 KB | Output is correct |
28 | Correct | 59 ms | 26012 KB | Output is correct |
29 | Correct | 27 ms | 26012 KB | Output is correct |
30 | Correct | 4 ms | 26012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 3136 KB | Output is correct |
2 | Correct | 11 ms | 3136 KB | Output is correct |
3 | Correct | 28 ms | 4112 KB | Output is correct |
4 | Correct | 26 ms | 5052 KB | Output is correct |
5 | Correct | 32 ms | 6512 KB | Output is correct |
6 | Correct | 22 ms | 6908 KB | Output is correct |
7 | Correct | 6 ms | 6908 KB | Output is correct |
8 | Correct | 23 ms | 8056 KB | Output is correct |
9 | Correct | 68 ms | 10972 KB | Output is correct |
10 | Correct | 30 ms | 11516 KB | Output is correct |
11 | Correct | 2 ms | 11516 KB | Output is correct |
12 | Correct | 2 ms | 11516 KB | Output is correct |
13 | Correct | 2 ms | 11516 KB | Output is correct |
14 | Correct | 3 ms | 11516 KB | Output is correct |
15 | Correct | 2 ms | 11516 KB | Output is correct |
16 | Correct | 3 ms | 11516 KB | Output is correct |
17 | Correct | 3 ms | 11516 KB | Output is correct |
18 | Correct | 2 ms | 11516 KB | Output is correct |
19 | Correct | 2 ms | 11516 KB | Output is correct |
20 | Correct | 2 ms | 11516 KB | Output is correct |
21 | Correct | 2 ms | 11516 KB | Output is correct |
22 | Correct | 2 ms | 11516 KB | Output is correct |
23 | Correct | 3 ms | 11516 KB | Output is correct |
24 | Correct | 3 ms | 11516 KB | Output is correct |
25 | Correct | 2 ms | 11516 KB | Output is correct |
26 | Correct | 19 ms | 11744 KB | Output is correct |
27 | Correct | 46 ms | 13984 KB | Output is correct |
28 | Correct | 59 ms | 15856 KB | Output is correct |
29 | Correct | 151 ms | 17184 KB | Output is correct |
30 | Correct | 172 ms | 18888 KB | Output is correct |
31 | Correct | 41 ms | 19952 KB | Output is correct |
32 | Correct | 2 ms | 19952 KB | Output is correct |
33 | Correct | 35 ms | 20008 KB | Output is correct |
34 | Correct | 52 ms | 22184 KB | Output is correct |
35 | Correct | 9 ms | 22184 KB | Output is correct |
36 | Correct | 35 ms | 22824 KB | Output is correct |
37 | Correct | 50 ms | 23996 KB | Output is correct |
38 | Correct | 59 ms | 26012 KB | Output is correct |
39 | Correct | 27 ms | 26012 KB | Output is correct |
40 | Correct | 4 ms | 26012 KB | Output is correct |
41 | Correct | 148 ms | 28392 KB | Output is correct |
42 | Correct | 66 ms | 30800 KB | Output is correct |
43 | Correct | 91 ms | 32648 KB | Output is correct |
44 | Correct | 63 ms | 35028 KB | Output is correct |
45 | Correct | 64 ms | 37472 KB | Output is correct |
46 | Correct | 155 ms | 39564 KB | Output is correct |
47 | Correct | 49 ms | 41544 KB | Output is correct |
48 | Correct | 74 ms | 43824 KB | Output is correct |
49 | Correct | 60 ms | 45704 KB | Output is correct |
50 | Correct | 598 ms | 47860 KB | Output is correct |
51 | Correct | 642 ms | 50412 KB | Output is correct |
52 | Correct | 592 ms | 52468 KB | Output is correct |
53 | Correct | 643 ms | 54908 KB | Output is correct |
54 | Correct | 587 ms | 56932 KB | Output is correct |
55 | Correct | 661 ms | 59440 KB | Output is correct |
56 | Correct | 566 ms | 61312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 592 KB | Output is correct |
4 | Correct | 3 ms | 600 KB | Output is correct |
5 | Correct | 2 ms | 600 KB | Output is correct |
6 | Correct | 2 ms | 600 KB | Output is correct |
7 | Correct | 3 ms | 684 KB | Output is correct |
8 | Correct | 2 ms | 684 KB | Output is correct |
9 | Correct | 37 ms | 3136 KB | Output is correct |
10 | Correct | 11 ms | 3136 KB | Output is correct |
11 | Correct | 28 ms | 4112 KB | Output is correct |
12 | Correct | 26 ms | 5052 KB | Output is correct |
13 | Correct | 32 ms | 6512 KB | Output is correct |
14 | Correct | 22 ms | 6908 KB | Output is correct |
15 | Correct | 6 ms | 6908 KB | Output is correct |
16 | Correct | 23 ms | 8056 KB | Output is correct |
17 | Correct | 68 ms | 10972 KB | Output is correct |
18 | Correct | 30 ms | 11516 KB | Output is correct |
19 | Correct | 2 ms | 11516 KB | Output is correct |
20 | Correct | 2 ms | 11516 KB | Output is correct |
21 | Correct | 2 ms | 11516 KB | Output is correct |
22 | Correct | 3 ms | 11516 KB | Output is correct |
23 | Correct | 2 ms | 11516 KB | Output is correct |
24 | Correct | 3 ms | 11516 KB | Output is correct |
25 | Correct | 3 ms | 11516 KB | Output is correct |
26 | Correct | 2 ms | 11516 KB | Output is correct |
27 | Correct | 2 ms | 11516 KB | Output is correct |
28 | Correct | 2 ms | 11516 KB | Output is correct |
29 | Correct | 2 ms | 11516 KB | Output is correct |
30 | Correct | 2 ms | 11516 KB | Output is correct |
31 | Correct | 3 ms | 11516 KB | Output is correct |
32 | Correct | 3 ms | 11516 KB | Output is correct |
33 | Correct | 2 ms | 11516 KB | Output is correct |
34 | Correct | 19 ms | 11744 KB | Output is correct |
35 | Correct | 46 ms | 13984 KB | Output is correct |
36 | Correct | 59 ms | 15856 KB | Output is correct |
37 | Correct | 151 ms | 17184 KB | Output is correct |
38 | Correct | 172 ms | 18888 KB | Output is correct |
39 | Correct | 41 ms | 19952 KB | Output is correct |
40 | Correct | 2 ms | 19952 KB | Output is correct |
41 | Correct | 35 ms | 20008 KB | Output is correct |
42 | Correct | 52 ms | 22184 KB | Output is correct |
43 | Correct | 9 ms | 22184 KB | Output is correct |
44 | Correct | 35 ms | 22824 KB | Output is correct |
45 | Correct | 50 ms | 23996 KB | Output is correct |
46 | Correct | 59 ms | 26012 KB | Output is correct |
47 | Correct | 27 ms | 26012 KB | Output is correct |
48 | Correct | 4 ms | 26012 KB | Output is correct |
49 | Correct | 148 ms | 28392 KB | Output is correct |
50 | Correct | 66 ms | 30800 KB | Output is correct |
51 | Correct | 91 ms | 32648 KB | Output is correct |
52 | Correct | 63 ms | 35028 KB | Output is correct |
53 | Correct | 64 ms | 37472 KB | Output is correct |
54 | Correct | 155 ms | 39564 KB | Output is correct |
55 | Correct | 49 ms | 41544 KB | Output is correct |
56 | Correct | 74 ms | 43824 KB | Output is correct |
57 | Correct | 60 ms | 45704 KB | Output is correct |
58 | Correct | 598 ms | 47860 KB | Output is correct |
59 | Correct | 642 ms | 50412 KB | Output is correct |
60 | Correct | 592 ms | 52468 KB | Output is correct |
61 | Correct | 643 ms | 54908 KB | Output is correct |
62 | Correct | 587 ms | 56932 KB | Output is correct |
63 | Correct | 661 ms | 59440 KB | Output is correct |
64 | Correct | 566 ms | 61312 KB | Output is correct |
65 | Correct | 3 ms | 61312 KB | Output is correct |
66 | Correct | 2 ms | 61312 KB | Output is correct |
67 | Execution timed out | 2055 ms | 63724 KB | Time limit exceeded |
68 | Halted | 0 ms | 0 KB | - |