제출 #476233

#제출 시각아이디문제언어결과실행 시간메모리
476233rainboyStrah (COCI18_strah)C11
110 / 110
317 ms66800 KiB
#include <stdio.h> #include <string.h> #define N 2000 #define M 2000 int main() { static char cc[N][M + 1]; static int kk[N][M], pp[N][M], qq[N][M], hh[N * M], cnt[M + 2]; int n, m, h, i, j, k; long long ans, x; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) scanf("%s", cc[i]); for (i = 0; i < n; i++) for (j = m - 1, k = 0; j >= 0; j--) kk[i][j] = k = cc[i][j] == '#' ? 0 : k + 1; memset(cnt, 0, (m + 2) * sizeof *cnt); for (i = 0; i < n; i++) for (j = 0; j < m; j++) cnt[kk[i][j] + 1]++; for (k = 1; k <= m + 1; k++) cnt[k] += cnt[k - 1]; for (i = 0; i < n; i++) for (j = 0; j < m; j++) hh[cnt[kk[i][j]]++] = i * m + j; for (i = 0; i < n; i++) for (j = 0; j < m; j++) pp[i][j] = i - 1, qq[i][j] = i + 1; x = 0; ans = 0; for (k = m, h = n * m - 1; k >= 1; k--) { while (h >= 0 && kk[hh[h] / m][hh[h] % m] == k) { int p, q; i = hh[h] / m, j = hh[h] % m, p = pp[i][j], q = qq[i][j]; x -= (long long) (i - p + 1) * (i - p) * (i - p - 1) / 6; x -= (long long) (q - i + 1) * (q - i) * (q - i - 1) / 6; x += (long long) (q - p + 1) * (q - p) * (q - p - 1) / 6; if (p != -1) qq[p][j] = q; if (q != n) pp[q][j] = p; h--; } ans += x * k; } printf("%lld\n", ans); return 0; }

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

strah.c: In function 'main':
strah.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
strah.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%s", cc[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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...