| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 47425 | tincamatei | Chessboard (IZhO18_chessboard) | C++14 | 140 ms | 2224 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 <cstdio>
const int MAX_N = 100000;
int x1[MAX_N], y1[MAX_N], x2[MAX_N], y2[MAX_N];
int main() {
  int n, k;
  long long mismatch, best = 10000000000LL;
  scanf("%d%d", &n, &k);
  for(int i = 0; i < k; ++i) {
    scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
    x1[i]--;y1[i]--;
    x2[i]--;y2[i]--;
  }
  for(int lat = 1; lat < n; ++lat)
    if(n % lat == 0) { 
      mismatch = 0;
      for(int i = 0; i < k; ++i)
        if((x1[i]/lat + y1[i]/lat) % 2 == 0)
          ++mismatch;
      mismatch = mismatch * 2 - k;
      if(mismatch + (long long)n * n / lat / lat / 2 * lat * lat < best)
        best = mismatch + (long long)n * n / lat / lat / 2 * lat * lat;
      mismatch = -mismatch;
      if(mismatch + ((long long)n * n / lat / lat + 1) / 2 * lat * lat < best)
        best = mismatch + ((long long)n * n / lat / lat + 1) / 2 * lat * lat;
    }
  printf("%lld", best);
  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... | ||||
