이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#define NM 200000
int aa[NM], n, m;
void dfs(int i, int j, int a, int c) {
if (i < 0 || i >= n || j < 0 || j >= m || aa[i * m + j] != a)
return;
aa[i * m + j] = c;
dfs(i - 1, j, a, c);
dfs(i + 1, j, a, c);
dfs(i, j - 1, a, c);
dfs(i, j + 1, a, c);
}
int main() {
int q, i, j;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
scanf("%d", &aa[i * m + j]);
scanf("%d", &q);
while (q--) {
int c;
scanf("%d%d%d", &i, &j, &c), i--, j--;
if (aa[i * m + j] != c)
dfs(i, j, aa[i * m + j], c);
}
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++)
printf("%d ", aa[i * m + j]);
printf("\n");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
paint.c: In function 'main':
paint.c:20:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
paint.c:23:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d", &aa[i * m + j]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
paint.c:24:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d", &q);
| ^~~~~~~~~~~~~~~
paint.c:28:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | scanf("%d%d%d", &i, &j, &c), i--, j--;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |