Submission #944505

#TimeUsernameProblemLanguageResultExecution timeMemory
944505rainboy수족관 1 (KOI13_aqua1)C11
100 / 100
2 ms600 KiB
#include <stdio.h> #define N 2500 int main() { static int xx[N + 1], yy[N], ll[N], rr[N], pp[N], qu[N]; static char empty[N]; int n, k, cnt, i, lower, upper, x, ans; scanf("%d%*d%*d", &n), n = n / 2 - 1; xx[0] = 0; for (i = 0; i < n; i++) scanf("%*d%*d%d%d", &xx[i + 1], &yy[i]); scanf("%*d%*d"); cnt = 0; for (i = 0; i < n; i++) { while (cnt && yy[qu[cnt - 1]] > yy[i]) cnt--; ll[i] = cnt == 0 ? -1 : qu[cnt - 1]; qu[cnt++] = i; } cnt = 0; for (i = n - 1; i >= 0; i--) { while (cnt && yy[qu[cnt - 1]] >= yy[i]) cnt--; rr[i] = cnt == 0 ? n : qu[cnt - 1]; qu[cnt++] = i; } for (i = 0; i < n; i++) pp[i] = rr[i] == n || ll[i] != -1 && yy[ll[i]] > yy[rr[i]] ? ll[i] : rr[i]; scanf("%d", &k); while (k--) { scanf("%d%*d%*d%*d", &x); lower = 0, upper = n; while (upper - lower > 1) { i = (lower + upper) / 2; if (xx[i] <= x) lower = i; else upper = i; } i = lower; while (i != -1 && !empty[i]) empty[i] = 1, i = pp[i]; } ans = 0; for (i = 0; i < n; i++) if (!empty[i]) ans += (xx[rr[i]] - xx[ll[i] + 1]) * (yy[i] - yy[pp[i]]); printf("%d\n", ans); return 0; }

Compilation message (stderr)

aqua1.c: In function 'main':
aqua1.c:30:37: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   30 |   pp[i] = rr[i] == n || ll[i] != -1 && yy[ll[i]] > yy[rr[i]] ? ll[i] : rr[i];
      |                         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
aqua1.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d%*d%*d", &n), n = n / 2 - 1;
      |  ^~~~~~~~~~~~~~~~~~~~~
aqua1.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%*d%*d%d%d", &xx[i + 1], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aqua1.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%*d%*d");
      |  ^~~~~~~~~~~~~~~
aqua1.c:31:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  scanf("%d", &k);
      |  ^~~~~~~~~~~~~~~
aqua1.c:33:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d%*d%*d%*d", &x);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...