Submission #844058

# Submission time Handle Problem Language Result Execution time Memory
844058 2023-09-05T05:25:49 Z GrandTiger1729 Chessboard (IZhO18_chessboard) C++17
8 / 100
23 ms 1628 KB
#include <bits/stdc++.h>
using namespace std;

struct Data
{
    int x1, y1, x2, y2;
    Data() = default;
    Data(int _x1, int _y1, int _x2, int _y2) : x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}
};

const long long INF = 1e18;
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int M, n; cin >> M >> n;
    vector<Data> a(n);
    for (int i = 0; i < n; i++)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1--, y1--;
        a[i] = Data(x1, y1, x2, y2);
    }
    auto solve = [&](int K) -> long long
    {
        long long ret1 = 1ll * (M / K) * (M / K) / 2 + M / K % 2;
        for (int i = 0; i < n; i++)
        {
            int xx = a[i].x1 / K, yy = a[i].y1 / K;
            if ((xx + yy) % 2 == 0)
                ret1--;
            else
                ret1++;
        }
        long long ret2 = 1ll * (M / K) * (M / K) / 2;
        for (int i = 0; i < n; i++)
        {
            int xx = a[i].x1 / K, yy = a[i].y1 / K;
            if ((xx + yy) % 2 == 1)
                ret2--;
            else
                ret2++;
        }
        return min(ret1, ret2);
    };
    long long ans = INF;
    for (int t = 1; t < M; t++)
        if (M % t == 0)
            ans = min(ans, solve(t));
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1524 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 11 ms 860 KB Output is correct
4 Correct 12 ms 1116 KB Output is correct
5 Correct 14 ms 1116 KB Output is correct
6 Correct 9 ms 860 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 10 ms 860 KB Output is correct
9 Correct 23 ms 1628 KB Output is correct
10 Correct 13 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1524 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 11 ms 860 KB Output is correct
4 Correct 12 ms 1116 KB Output is correct
5 Correct 14 ms 1116 KB Output is correct
6 Correct 9 ms 860 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 10 ms 860 KB Output is correct
9 Correct 23 ms 1628 KB Output is correct
10 Correct 13 ms 1116 KB Output is correct
11 Incorrect 0 ms 344 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -