Submission #378686

# Submission time Handle Problem Language Result Execution time Memory
378686 2021-03-17T03:11:07 Z abc864197532 Chessboard (IZhO18_chessboard) C++17
70 / 100
674 ms 5100 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int, int>
#define pll pair<lli, lli>
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define test(x) cout << #x << ' ' << x << endl
#define printv(x) {\
    for (auto a : x) cout << x << ' ';\
    cout << endl;\
}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int N = 2000000;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> p;
    for (int i = 1; i < n; ++i) if (n % i == 0) p.pb(i);
    if (k == 0) {
        lli ans = 1ll * n * n;
        for (int i : p) {
            ans = min(ans, 1ll * i * i * (1ll * (n / i) * (n / i) / 2));
        }
        cout << ans << endl;
        return 0;
    }
    set <pii> s;
    for (int i = 0, x1, y1, x2, y2; i < k; ++i) {
        cin >> x1 >> y1 >> x2 >> y2, --x1, --y1;
        s.insert({x1, y1});
    }
    lli ans = 1ll * n * n;
    for (int i : p) {
        lli cur = 1ll * i * i * (1ll * (n / i) * (n / i) / 2);
        for (pii a : s) {
            int x, y;
            tie(x, y) = a;
            x /= i, y /= i;
            if ((x ^ y) & 1) {
                cur--;
            } else {
                cur++;
            }
        }
        ans = min({ans, cur, 1ll * n * n - cur});
    }
    cout << ans << endl;
}

/*
6 8
3 3 3 3
1 2 1 2
3 4 3 4
5 5 5 5
4 3 4 3
4 4 4 4
2 1 2 1
3 6 3 6
 */
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 3308 KB Output is correct
2 Correct 12 ms 1132 KB Output is correct
3 Correct 28 ms 2156 KB Output is correct
4 Correct 32 ms 2540 KB Output is correct
5 Correct 42 ms 3052 KB Output is correct
6 Correct 31 ms 2024 KB Output is correct
7 Correct 5 ms 620 KB Output is correct
8 Correct 25 ms 2028 KB Output is correct
9 Correct 75 ms 4588 KB Output is correct
10 Correct 50 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 19 ms 1664 KB Output is correct
17 Correct 66 ms 4312 KB Output is correct
18 Correct 97 ms 4972 KB Output is correct
19 Correct 139 ms 4460 KB Output is correct
20 Correct 172 ms 4960 KB Output is correct
21 Correct 61 ms 4160 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 34 ms 2284 KB Output is correct
24 Correct 76 ms 4524 KB Output is correct
25 Correct 6 ms 748 KB Output is correct
26 Correct 42 ms 3052 KB Output is correct
27 Correct 73 ms 3564 KB Output is correct
28 Correct 76 ms 4844 KB Output is correct
29 Correct 24 ms 1900 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 3308 KB Output is correct
2 Correct 12 ms 1132 KB Output is correct
3 Correct 28 ms 2156 KB Output is correct
4 Correct 32 ms 2540 KB Output is correct
5 Correct 42 ms 3052 KB Output is correct
6 Correct 31 ms 2024 KB Output is correct
7 Correct 5 ms 620 KB Output is correct
8 Correct 25 ms 2028 KB Output is correct
9 Correct 75 ms 4588 KB Output is correct
10 Correct 50 ms 2668 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 19 ms 1664 KB Output is correct
27 Correct 66 ms 4312 KB Output is correct
28 Correct 97 ms 4972 KB Output is correct
29 Correct 139 ms 4460 KB Output is correct
30 Correct 172 ms 4960 KB Output is correct
31 Correct 61 ms 4160 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 34 ms 2284 KB Output is correct
34 Correct 76 ms 4524 KB Output is correct
35 Correct 6 ms 748 KB Output is correct
36 Correct 42 ms 3052 KB Output is correct
37 Correct 73 ms 3564 KB Output is correct
38 Correct 76 ms 4844 KB Output is correct
39 Correct 24 ms 1900 KB Output is correct
40 Correct 2 ms 492 KB Output is correct
41 Correct 136 ms 4204 KB Output is correct
42 Correct 91 ms 4716 KB Output is correct
43 Correct 101 ms 4404 KB Output is correct
44 Correct 76 ms 4588 KB Output is correct
45 Correct 82 ms 4972 KB Output is correct
46 Correct 130 ms 4712 KB Output is correct
47 Correct 69 ms 4332 KB Output is correct
48 Correct 104 ms 4588 KB Output is correct
49 Correct 72 ms 4328 KB Output is correct
50 Correct 611 ms 4716 KB Output is correct
51 Correct 674 ms 4936 KB Output is correct
52 Correct 553 ms 4716 KB Output is correct
53 Correct 545 ms 4832 KB Output is correct
54 Correct 452 ms 4588 KB Output is correct
55 Correct 647 ms 5100 KB Output is correct
56 Correct 359 ms 4332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 46 ms 3308 KB Output is correct
10 Correct 12 ms 1132 KB Output is correct
11 Correct 28 ms 2156 KB Output is correct
12 Correct 32 ms 2540 KB Output is correct
13 Correct 42 ms 3052 KB Output is correct
14 Correct 31 ms 2024 KB Output is correct
15 Correct 5 ms 620 KB Output is correct
16 Correct 25 ms 2028 KB Output is correct
17 Correct 75 ms 4588 KB Output is correct
18 Correct 50 ms 2668 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 19 ms 1664 KB Output is correct
35 Correct 66 ms 4312 KB Output is correct
36 Correct 97 ms 4972 KB Output is correct
37 Correct 139 ms 4460 KB Output is correct
38 Correct 172 ms 4960 KB Output is correct
39 Correct 61 ms 4160 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 34 ms 2284 KB Output is correct
42 Correct 76 ms 4524 KB Output is correct
43 Correct 6 ms 748 KB Output is correct
44 Correct 42 ms 3052 KB Output is correct
45 Correct 73 ms 3564 KB Output is correct
46 Correct 76 ms 4844 KB Output is correct
47 Correct 24 ms 1900 KB Output is correct
48 Correct 2 ms 492 KB Output is correct
49 Correct 136 ms 4204 KB Output is correct
50 Correct 91 ms 4716 KB Output is correct
51 Correct 101 ms 4404 KB Output is correct
52 Correct 76 ms 4588 KB Output is correct
53 Correct 82 ms 4972 KB Output is correct
54 Correct 130 ms 4712 KB Output is correct
55 Correct 69 ms 4332 KB Output is correct
56 Correct 104 ms 4588 KB Output is correct
57 Correct 72 ms 4328 KB Output is correct
58 Correct 611 ms 4716 KB Output is correct
59 Correct 674 ms 4936 KB Output is correct
60 Correct 553 ms 4716 KB Output is correct
61 Correct 545 ms 4832 KB Output is correct
62 Correct 452 ms 4588 KB Output is correct
63 Correct 647 ms 5100 KB Output is correct
64 Correct 359 ms 4332 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Incorrect 1 ms 364 KB Output isn't correct
67 Halted 0 ms 0 KB -