Submission #768770

#TimeUsernameProblemLanguageResultExecution timeMemory
768770rainboyChessboard (IZhO18_chessboard)C11
100 / 100
290 ms4228 KiB
#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)

chessboard.c: In function 'main':
chessboard.c:18:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d%d", &s, &n);
      |  ^~~~~~~~~~~~~~~~~~~~~
chessboard.c:20:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d%d%d%d", &xx1[i], &yy1[i], &xx2[i], &yy2[i]), xx1[i]--, yy1[i]--;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...