제출 #710792

#제출 시각아이디문제언어결과실행 시간메모리
710792rainboySkyscraper (JOI16_skyscraper)C11
100 / 100
171 ms3432 KiB
#include <stdio.h> #define N 100 #define L 1000 #define MD 1000000007 unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } void sort(int *aa, int l, int r) { while (l < r) { int i = l, j = l, k = r, a = aa[l + rand_() % (r - l)], tmp; while (j < k) if (aa[j] == a) j++; else if (aa[j] < a) { tmp = aa[i], aa[i] = aa[j], aa[j] = tmp; i++, j++; } else { k--; tmp = aa[j], aa[j] = aa[k], aa[k] = tmp; } sort(aa, l, i); l = k; } } int main() { static int aa[N], dp[N + 1][L + 1][2][2], dq[N + 1][L + 1][2][2]; int n, l, i, c, d, d_, s, t, a, ans; scanf("%d%d", &n, &l); if (n == 1) { printf("1\n"); return 0; } for (i = 0; i < n; i++) scanf("%d", &aa[i]); sort(aa, 0, n); dp[0][0][0][0] = 1; for (i = 0; i + 1 < n; i++) { for (c = 0; c <= n; c++) for (d = 0; d <= l; d++) for (s = 0; s < 2; s++) for (t = 0; t < 2; t++) dq[c][d][s][t] = 0; for (c = 0; c <= n; c++) for (d = 0; d <= l; d++) for (s = 0; s < 2; s++) for (t = 0; t < 2; t++) { int x = dp[c][d][s][t]; if (x == 0) continue; dq[c + 1][d][s][t] = (dq[c + 1][d][s][t] + x) % MD; if (s == 0) dq[c + 1][d][1][t] = (dq[c + 1][d][1][t] + x) % MD; if (t == 0) dq[c + 1][d][s][1] = (dq[c + 1][d][s][1] + x) % MD; dq[c][d][s][t] = (dq[c][d][s][t] + (long long) x * (c * 2 - s - t)) % MD; if (s == 0) dq[c][d][1][t] = (dq[c][d][1][t] + (long long) x * (c - t)) % MD; if (t == 0) dq[c][d][s][1] = (dq[c][d][s][1] + (long long) x * (c - s)) % MD; if (c > 0) dq[c - 1][d][s][t] = (dq[c - 1][d][s][t] + (long long) x * ((c - s - t) * (c - s - t - 1) + (c - s - t) * (s + t))) % MD; } a = aa[i + 1] - aa[i]; for (c = 0; c <= n; c++) for (d = 0; d <= l; d++) for (s = 0; s < 2; s++) for (t = 0; t < 2; t++) if (s + t <= c * 2) { d_ = a * (c * 2 - s - t); dp[c][d][s][t] = d < d_ ? 0 : dq[c][d - d_][s][t]; } } ans = 0; for (d = 0; d <= l; d++) ans = ((long long) ans + dp[1][d][1][0] + dp[1][d][0][1] + dp[2][d][1][1]) % MD; printf("%d\n", ans); return 0; }

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

skyscraper.c: In function 'main':
skyscraper.c:36:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  scanf("%d%d", &n, &l);
      |  ^~~~~~~~~~~~~~~~~~~~~
skyscraper.c:42:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...