# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153924 | theboatman | Chessboard (IZhO18_chessboard) | C++17 | 664 ms | 5804 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define y1 theboatman
#define make_struct(args...) {args}
#define int long long
using namespace std;
struct sqr {
int x, y, x1, y1;
};
int get(int n, int len, vector <sqr> &a) {
int col_sqr = (n * n) / (len * len);
int res = (col_sqr / 2) * len * len;
for(auto i : a) {
int x = i.x, y = i.y;
int color = (i.x - 1) / len + (i.y - 1) / len;
if (color % 2 == 0) {
res++;
}
else {
res--;
}
}
int res1 = ( (col_sqr + 1) / 2) * len * len;
for(auto i : a) {
int x = i.x, y = i.y;
int color = (i.x - 1) / len + (i.y - 1) / len;
if (color % 2 == 1) {
res1++;
}
else {
res1--;
}
}
return min(res, res1);
}
int32_t main() {
cin.tie(0);
ios :: sync_with_stdio(0);
int n, k;
cin >> n >> k;
vector <sqr> a(k);
for(int i = 0; i < k; i++) {
cin >> a[i].x >> a[i].y >> a[i].x1 >> a[i].y1;
}
int ans = n * n;
for(int i = 1; i < n; i++) {
if (n % i == 0) {
ans = min(ans, get(n, i, a));
}
}
cout << ans << "\n";
return 0;
}
/*
cost: ???
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |