(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #814809

#제출 시각아이디문제언어결과실행 시간메모리
814809rainboyGarden (JOI23_garden)C11
100 / 100
1604 ms122660 KiB
#include <stdio.h> #define N 5000 int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int main() { static char uu[N], vv[N], ww[N][N]; static int aa[N], aaa[N][N], qu[N], pp[N], qq[N]; int n, m1, m2, cnt, i, i_, j, a, ans; scanf("%d%d%d", &m1, &m2, &n); while (m1--) { scanf("%d%d", &i, &j); uu[i] = 1, vv[j] = 1; } while (m2--) { scanf("%d%d", &i, &j); ww[i][j] = 1; } for (i = 0; i < n; i++) for (j = 0; j < n; j++) if (ww[i][j]) { i_ = i, a = n; do aaa[i_ = (i_ + 1) % n][j] = a--; while (!ww[i_][j]); } a = n - 1; while (!uu[a]) a--; a++; ans = n * n; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) aa[j] = vv[j] ? n + 1 : max(aaa[i][j], a); cnt = 0; for (j = 0; j < n; j++) { while (cnt && aa[qu[cnt - 1]] <= aa[j]) cnt--; qu[cnt++] = j; } for (j = 0; j < n; j++) { while (cnt && aa[qu[cnt - 1]] <= aa[j]) cnt--; if (cnt == 0) pp[j] = -1; else { pp[j] = qu[cnt - 1]; if (pp[j] > j) pp[j] -= n; } qu[cnt++] = j; } cnt = 0; for (j = n - 1; j >= 0; j--) { while (cnt && aa[qu[cnt - 1]] <= aa[j]) cnt--; qu[cnt++] = j; } for (j = n - 1; j >= 0; j--) { while (cnt && aa[qu[cnt - 1]] <= aa[j]) cnt--; if (cnt == 0) qq[j] = -1; else { qq[j] = qu[cnt - 1]; if (qq[j] < j) qq[j] += n; } qu[cnt++] = j; } ans = min(ans, a * n); for (j = 0; j < n; j++) if (aa[j] != n + 1) ans = min(ans, aa[j] * (n - (qq[j] - pp[j] - 1))); a = uu[i] ? n : a - 1; } printf("%d\n", ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

garden.c: In function 'main':
garden.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d%d", &m1, &m2, &n);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
garden.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d%d", &i, &j);
      |   ^~~~~~~~~~~~~~~~~~~~~
garden.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d%d", &i, &j);
      |   ^~~~~~~~~~~~~~~~~~~~~
#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...