# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
768770 | rainboy | Chessboard (IZhO18_chessboard) | C11 | 290 ms | 4228 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 <stdio.h>
#define N 100000
#define INF 0x3f3f3f3f3f3f3f3fLL
long long min(long long a, long long b) { return a < b ? a : b; }
int f(int s, int a) {
a %= s * 2;
return min(a, s * 2 - a);
}
int main() {
static int xx1[N], yy1[N], xx2[N], yy2[N];
int n, s, t, i;
long long k, k_;
scanf("%d%d", &s, &n);
for (i = 0; i < n; i++)
scanf("%d%d%d%d", &xx1[i], &yy1[i], &xx2[i], &yy2[i]), xx1[i]--, yy1[i]--;
k_ = INF;
for (t = 1; t < s; t++)
if (s % t == 0) {
k = (long long) (s / t) * (s / t) / 2 * t * t;
for (i = 0; i < n; i++)
k += (long long) (f(t, xx2[i]) - f(t, xx1[i])) * (f(t, yy2[i]) - f(t, yy1[i]));
k_ = min(k_, min(k, (long long) s * s - k));
}
printf("%lld\n", k_);
return 0;
}
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... |