이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#define N 3000
#define M 3000
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int ft[N];
void update(int i, int n, int x) {
while (i < n) {
ft[i] = max(ft[i], x);
i |= i + 1;
}
}
int query(int i) {
int x = 0;
while (i >= 0) {
x = max(x, ft[i]);
i &= i + 1, i--;
}
return x;
}
int main() {
static char cc[N][M + 1];
int n, m, i, j, ij, k;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
scanf("%s", cc[i]);
k = 0;
for (ij = 0; ij <= (n - 1) + (m - 1); ij++) {
memset(ft, 0, m * sizeof *ft);
for (i = min(ij, n - 1), j = ij - i; i >= 0 && j < m; i--, j++) {
if (j + 2 < m && cc[i][j] == 'R' && cc[i][j + 1] == 'G' && cc[i][j + 2] == 'W')
update(j + 2, m, query(j + 1) + 1);
if (i + 2 < n && cc[i][j] == 'R' && cc[i + 1][j] == 'G' && cc[i + 2][j] == 'W')
update(j, m, query(j - 1) + 1);
}
k += query(m - 1);
}
printf("%d\n", k);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
dango_maker.c: In function 'main':
dango_maker.c:33:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
dango_maker.c:35:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | scanf("%s", cc[i]);
| ^~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |