Submission #90126

# Submission time Handle Problem Language Result Execution time Memory
90126 2018-12-20T13:25:29 Z adlet Chessboard (IZhO18_chessboard) C++17
0 / 100
89 ms 932 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;

typedef long long ll;

const int N = 1e5 + 5;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);

int n, k;

ll ans = INF;

vector < int > v;

int get(int x1, int y1, int d) {
    x1 /= d;
    y1 /= d;
    return ((x1 % 2) == (y1 % 2));
}
int x[N], y[N];

int main() {
    cin >> n >> k;
    for (int i = 1; i <= k; ++i) {
        int x2, y2;
        cin >> x[i] >> y[i] >> x2 >> y2;
    }
    v.push_back(1);
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            v.push_back(i);
            if (n / i != i) {
                v.push_back(n / i);
            }
        }
    }
    for (int i : v) {
        int m = n / i, cnt_black = 0, cnt_white = 0;
        ll black = (((m * m) / 2) + (m * m) % 2) * (i * 1ll * i);
        ll white = (n * 1ll * n) - black;
        for (int j = 1; j <= k; ++j) {
            cnt_black += get(x[j] - 1, y[j] - 1, i);
        }
        cnt_white = k - cnt_black;
        cout << i << " " << cnt_black << " " << cnt_white << " " << black << " " << white << "\n";
        ll x = (black - cnt_black) + cnt_white;
        ll y = (white - cnt_white) + cnt_black;
        ans = min(ans, min(x, y));
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -