Submission #715003

# Submission time Handle Problem Language Result Execution time Memory
715003 2023-03-25T17:27:42 Z Stickfish Chessboard (IZhO18_chessboard) C++17
70 / 100
2000 ms 4240 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];
            for (int i = ld.first; i <= ru.first; ++i) for (int j = ld.second; j <= ru.second; ++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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 2676 KB Output is correct
2 Correct 18 ms 928 KB Output is correct
3 Correct 47 ms 1856 KB Output is correct
4 Correct 44 ms 1876 KB Output is correct
5 Correct 61 ms 2412 KB Output is correct
6 Correct 38 ms 1612 KB Output is correct
7 Correct 9 ms 528 KB Output is correct
8 Correct 44 ms 1588 KB Output is correct
9 Correct 101 ms 3740 KB Output is correct
10 Correct 57 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 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 2 ms 212 KB Output is correct
12 Correct 1 ms 212 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 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 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 2 ms 212 KB Output is correct
12 Correct 1 ms 212 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 1108 KB Output is correct
17 Correct 72 ms 2972 KB Output is correct
18 Correct 86 ms 3376 KB Output is correct
19 Correct 120 ms 3088 KB Output is correct
20 Correct 140 ms 3536 KB Output is correct
21 Correct 65 ms 2828 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 37 ms 1584 KB Output is correct
24 Correct 87 ms 3088 KB Output is correct
25 Correct 11 ms 468 KB Output is correct
26 Correct 51 ms 2056 KB Output is correct
27 Correct 58 ms 2364 KB Output is correct
28 Correct 83 ms 3308 KB Output is correct
29 Correct 29 ms 1324 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 2676 KB Output is correct
2 Correct 18 ms 928 KB Output is correct
3 Correct 47 ms 1856 KB Output is correct
4 Correct 44 ms 1876 KB Output is correct
5 Correct 61 ms 2412 KB Output is correct
6 Correct 38 ms 1612 KB Output is correct
7 Correct 9 ms 528 KB Output is correct
8 Correct 44 ms 1588 KB Output is correct
9 Correct 101 ms 3740 KB Output is correct
10 Correct 57 ms 2252 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 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 308 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 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 2 ms 212 KB Output is correct
22 Correct 1 ms 212 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 1108 KB Output is correct
27 Correct 72 ms 2972 KB Output is correct
28 Correct 86 ms 3376 KB Output is correct
29 Correct 120 ms 3088 KB Output is correct
30 Correct 140 ms 3536 KB Output is correct
31 Correct 65 ms 2828 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 37 ms 1584 KB Output is correct
34 Correct 87 ms 3088 KB Output is correct
35 Correct 11 ms 468 KB Output is correct
36 Correct 51 ms 2056 KB Output is correct
37 Correct 58 ms 2364 KB Output is correct
38 Correct 83 ms 3308 KB Output is correct
39 Correct 29 ms 1324 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 119 ms 3496 KB Output is correct
42 Correct 108 ms 4016 KB Output is correct
43 Correct 110 ms 3504 KB Output is correct
44 Correct 110 ms 3892 KB Output is correct
45 Correct 137 ms 4112 KB Output is correct
46 Correct 125 ms 3916 KB Output is correct
47 Correct 98 ms 3788 KB Output is correct
48 Correct 101 ms 3696 KB Output is correct
49 Correct 96 ms 3628 KB Output is correct
50 Correct 240 ms 3884 KB Output is correct
51 Correct 249 ms 4116 KB Output is correct
52 Correct 232 ms 3744 KB Output is correct
53 Correct 252 ms 4096 KB Output is correct
54 Correct 233 ms 3808 KB Output is correct
55 Correct 263 ms 4240 KB Output is correct
56 Correct 227 ms 3708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 69 ms 2676 KB Output is correct
10 Correct 18 ms 928 KB Output is correct
11 Correct 47 ms 1856 KB Output is correct
12 Correct 44 ms 1876 KB Output is correct
13 Correct 61 ms 2412 KB Output is correct
14 Correct 38 ms 1612 KB Output is correct
15 Correct 9 ms 528 KB Output is correct
16 Correct 44 ms 1588 KB Output is correct
17 Correct 101 ms 3740 KB Output is correct
18 Correct 57 ms 2252 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 212 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 308 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 2 ms 212 KB Output is correct
30 Correct 1 ms 212 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 1108 KB Output is correct
35 Correct 72 ms 2972 KB Output is correct
36 Correct 86 ms 3376 KB Output is correct
37 Correct 120 ms 3088 KB Output is correct
38 Correct 140 ms 3536 KB Output is correct
39 Correct 65 ms 2828 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 37 ms 1584 KB Output is correct
42 Correct 87 ms 3088 KB Output is correct
43 Correct 11 ms 468 KB Output is correct
44 Correct 51 ms 2056 KB Output is correct
45 Correct 58 ms 2364 KB Output is correct
46 Correct 83 ms 3308 KB Output is correct
47 Correct 29 ms 1324 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 119 ms 3496 KB Output is correct
50 Correct 108 ms 4016 KB Output is correct
51 Correct 110 ms 3504 KB Output is correct
52 Correct 110 ms 3892 KB Output is correct
53 Correct 137 ms 4112 KB Output is correct
54 Correct 125 ms 3916 KB Output is correct
55 Correct 98 ms 3788 KB Output is correct
56 Correct 101 ms 3696 KB Output is correct
57 Correct 96 ms 3628 KB Output is correct
58 Correct 240 ms 3884 KB Output is correct
59 Correct 249 ms 4116 KB Output is correct
60 Correct 232 ms 3744 KB Output is correct
61 Correct 252 ms 4096 KB Output is correct
62 Correct 233 ms 3808 KB Output is correct
63 Correct 263 ms 4240 KB Output is correct
64 Correct 227 ms 3708 KB Output is correct
65 Correct 1 ms 220 KB Output is correct
66 Correct 1 ms 220 KB Output is correct
67 Execution timed out 2070 ms 3928 KB Time limit exceeded
68 Halted 0 ms 0 KB -