Submission #715005

# Submission time Handle Problem Language Result Execution time Memory
715005 2023-03-25T17:34:20 Z Stickfish Chessboard (IZhO18_chessboard) C++17
70 / 100
2000 ms 1852 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

bool get_color(pair<int, int> p, int d) {
    return (p.first / d + p.second / d) & 1;
}

signed main() {
    ll n, k;
    cin >> n >> k;
    vector<pair<pair<int, int>, pair<int, int>>> rect(k);
    for (int i = 0; i < k; ++i) {
        cin >> rect[i].first.first >> rect[i].first.second >> rect[i].second.first >> rect[i].second.second;
        --rect[i].first.first, --rect[i].first.second, --rect[i].second.first, --rect[i].second.second;
    }
    vector<ll> divs;
    for (int p = 1; p < n; ++p) {
        if (n % p == 0)
            divs.push_back(p);
    }
    int szd = divs.size();
    vector<ll> ans(szd);
    for (int di = 0; di < szd; ++di) {
        ll d = divs[di];
        if (n / d == 0)
            ans[di] = n * n / 2;
        else
            ans[di] = d * d * ((n / d) * (n / d) / 2);
    }
    for (auto [ld, ru] : rect) {
        for (int di = 0; di < szd; ++di) {
            ll d = divs[di];
            ll r = ld.first + (ru.first - ld.first) % (2 * d);
            ll u = ld.second + (ru.second - ld.second) % (2 * d);
            for (int i = ld.first; i <= r; ++i) for (int j = ld.second; j <= u; ++j) {
                if (get_color({i, j}, d))
                    --ans[di];
                else
                    ++ans[di];
            }
        }
    }
    ll mnans = n * n;
    for (auto x : ans) {
        mnans = min({mnans, x, n * n - x});
    }
    cout << mnans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 1 ms 216 KB Output is correct
7 Correct 0 ms 216 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 1236 KB Output is correct
2 Correct 18 ms 608 KB Output is correct
3 Correct 43 ms 916 KB Output is correct
4 Correct 51 ms 1000 KB Output is correct
5 Correct 58 ms 1140 KB Output is correct
6 Correct 36 ms 828 KB Output is correct
7 Correct 9 ms 412 KB Output is correct
8 Correct 36 ms 860 KB Output is correct
9 Correct 94 ms 1704 KB Output is correct
10 Correct 64 ms 1076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 224 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 224 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 25 ms 724 KB Output is correct
17 Correct 72 ms 1620 KB Output is correct
18 Correct 84 ms 1748 KB Output is correct
19 Correct 113 ms 1668 KB Output is correct
20 Correct 138 ms 1748 KB Output is correct
21 Correct 81 ms 1560 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 40 ms 852 KB Output is correct
24 Correct 74 ms 1696 KB Output is correct
25 Correct 9 ms 340 KB Output is correct
26 Correct 48 ms 1180 KB Output is correct
27 Correct 61 ms 1364 KB Output is correct
28 Correct 87 ms 1780 KB Output is correct
29 Correct 32 ms 804 KB Output is correct
30 Correct 3 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 1236 KB Output is correct
2 Correct 18 ms 608 KB Output is correct
3 Correct 43 ms 916 KB Output is correct
4 Correct 51 ms 1000 KB Output is correct
5 Correct 58 ms 1140 KB Output is correct
6 Correct 36 ms 828 KB Output is correct
7 Correct 9 ms 412 KB Output is correct
8 Correct 36 ms 860 KB Output is correct
9 Correct 94 ms 1704 KB Output is correct
10 Correct 64 ms 1076 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 224 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 216 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 25 ms 724 KB Output is correct
27 Correct 72 ms 1620 KB Output is correct
28 Correct 84 ms 1748 KB Output is correct
29 Correct 113 ms 1668 KB Output is correct
30 Correct 138 ms 1748 KB Output is correct
31 Correct 81 ms 1560 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 40 ms 852 KB Output is correct
34 Correct 74 ms 1696 KB Output is correct
35 Correct 9 ms 340 KB Output is correct
36 Correct 48 ms 1180 KB Output is correct
37 Correct 61 ms 1364 KB Output is correct
38 Correct 87 ms 1780 KB Output is correct
39 Correct 32 ms 804 KB Output is correct
40 Correct 3 ms 212 KB Output is correct
41 Correct 125 ms 1492 KB Output is correct
42 Correct 103 ms 1756 KB Output is correct
43 Correct 116 ms 1596 KB Output is correct
44 Correct 107 ms 1736 KB Output is correct
45 Correct 97 ms 1748 KB Output is correct
46 Correct 140 ms 1748 KB Output is correct
47 Correct 97 ms 1628 KB Output is correct
48 Correct 106 ms 1620 KB Output is correct
49 Correct 96 ms 1492 KB Output is correct
50 Correct 327 ms 1732 KB Output is correct
51 Correct 370 ms 1820 KB Output is correct
52 Correct 325 ms 1620 KB Output is correct
53 Correct 383 ms 1804 KB Output is correct
54 Correct 330 ms 1684 KB Output is correct
55 Correct 404 ms 1852 KB Output is correct
56 Correct 317 ms 1640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 1 ms 216 KB Output is correct
7 Correct 0 ms 216 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 73 ms 1236 KB Output is correct
10 Correct 18 ms 608 KB Output is correct
11 Correct 43 ms 916 KB Output is correct
12 Correct 51 ms 1000 KB Output is correct
13 Correct 58 ms 1140 KB Output is correct
14 Correct 36 ms 828 KB Output is correct
15 Correct 9 ms 412 KB Output is correct
16 Correct 36 ms 860 KB Output is correct
17 Correct 94 ms 1704 KB Output is correct
18 Correct 64 ms 1076 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 224 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 216 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 25 ms 724 KB Output is correct
35 Correct 72 ms 1620 KB Output is correct
36 Correct 84 ms 1748 KB Output is correct
37 Correct 113 ms 1668 KB Output is correct
38 Correct 138 ms 1748 KB Output is correct
39 Correct 81 ms 1560 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 40 ms 852 KB Output is correct
42 Correct 74 ms 1696 KB Output is correct
43 Correct 9 ms 340 KB Output is correct
44 Correct 48 ms 1180 KB Output is correct
45 Correct 61 ms 1364 KB Output is correct
46 Correct 87 ms 1780 KB Output is correct
47 Correct 32 ms 804 KB Output is correct
48 Correct 3 ms 212 KB Output is correct
49 Correct 125 ms 1492 KB Output is correct
50 Correct 103 ms 1756 KB Output is correct
51 Correct 116 ms 1596 KB Output is correct
52 Correct 107 ms 1736 KB Output is correct
53 Correct 97 ms 1748 KB Output is correct
54 Correct 140 ms 1748 KB Output is correct
55 Correct 97 ms 1628 KB Output is correct
56 Correct 106 ms 1620 KB Output is correct
57 Correct 96 ms 1492 KB Output is correct
58 Correct 327 ms 1732 KB Output is correct
59 Correct 370 ms 1820 KB Output is correct
60 Correct 325 ms 1620 KB Output is correct
61 Correct 383 ms 1804 KB Output is correct
62 Correct 330 ms 1684 KB Output is correct
63 Correct 404 ms 1852 KB Output is correct
64 Correct 317 ms 1640 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Execution timed out 2076 ms 1764 KB Time limit exceeded
68 Halted 0 ms 0 KB -