# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
491108 |
2021-11-30T14:44:54 Z |
rainboy |
Paint (COI20_paint) |
C |
|
3000 ms |
11024 KB |
#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;
}
Compilation message
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 |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
6 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
388 KB |
Output is correct |
5 |
Correct |
247 ms |
592 KB |
Output is correct |
6 |
Correct |
487 ms |
928 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
1584 KB |
Output is correct |
2 |
Correct |
126 ms |
2592 KB |
Output is correct |
3 |
Execution timed out |
3070 ms |
6408 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2428 ms |
11024 KB |
Output is correct |
2 |
Correct |
463 ms |
7620 KB |
Output is correct |
3 |
Correct |
540 ms |
8420 KB |
Output is correct |
4 |
Execution timed out |
3089 ms |
7312 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
3400 KB |
Output is correct |
2 |
Execution timed out |
3098 ms |
6724 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |