Submission #90127

# Submission time Handle Problem Language Result Execution time Memory
90127 2018-12-20T13:26:18 Z adlet Chessboard (IZhO18_chessboard) C++17
39 / 100
124 ms 1452 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;
        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 Correct 0 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Correct 2 ms 552 KB Output is correct
8 Correct 2 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 1064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1064 KB Output is correct
2 Correct 2 ms 1064 KB Output is correct
3 Correct 2 ms 1064 KB Output is correct
4 Correct 3 ms 1064 KB Output is correct
5 Correct 2 ms 1064 KB Output is correct
6 Correct 2 ms 1064 KB Output is correct
7 Correct 3 ms 1064 KB Output is correct
8 Correct 3 ms 1064 KB Output is correct
9 Correct 3 ms 1064 KB Output is correct
10 Correct 2 ms 1064 KB Output is correct
11 Correct 3 ms 1064 KB Output is correct
12 Correct 2 ms 1064 KB Output is correct
13 Correct 3 ms 1064 KB Output is correct
14 Correct 3 ms 1064 KB Output is correct
15 Correct 3 ms 1064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1064 KB Output is correct
2 Correct 2 ms 1064 KB Output is correct
3 Correct 2 ms 1064 KB Output is correct
4 Correct 3 ms 1064 KB Output is correct
5 Correct 2 ms 1064 KB Output is correct
6 Correct 2 ms 1064 KB Output is correct
7 Correct 3 ms 1064 KB Output is correct
8 Correct 3 ms 1064 KB Output is correct
9 Correct 3 ms 1064 KB Output is correct
10 Correct 2 ms 1064 KB Output is correct
11 Correct 3 ms 1064 KB Output is correct
12 Correct 2 ms 1064 KB Output is correct
13 Correct 3 ms 1064 KB Output is correct
14 Correct 3 ms 1064 KB Output is correct
15 Correct 3 ms 1064 KB Output is correct
16 Correct 31 ms 1064 KB Output is correct
17 Correct 89 ms 1244 KB Output is correct
18 Correct 103 ms 1324 KB Output is correct
19 Correct 112 ms 1324 KB Output is correct
20 Correct 124 ms 1452 KB Output is correct
21 Correct 84 ms 1452 KB Output is correct
22 Correct 3 ms 1452 KB Output is correct
23 Correct 47 ms 1452 KB Output is correct
24 Correct 94 ms 1452 KB Output is correct
25 Correct 11 ms 1452 KB Output is correct
26 Correct 61 ms 1452 KB Output is correct
27 Correct 73 ms 1452 KB Output is correct
28 Correct 99 ms 1452 KB Output is correct
29 Correct 36 ms 1452 KB Output is correct
30 Correct 5 ms 1452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 1064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Correct 2 ms 552 KB Output is correct
8 Correct 2 ms 552 KB Output is correct
9 Incorrect 88 ms 1064 KB Output isn't correct
10 Halted 0 ms 0 KB -