Submission #17715
Source Code Expand
#include <stdio.h>
int w, h;
int grid[20][20];
int spread;
void show(){
int i, j;
for(i = 0; i < h; i++){
for(j = 0; j < w; j++){
printf("%d ", grid[i][j]);
}
printf("\n");
}
}
void pour(int x, int y){
if(x + 1 < w){
if(grid[y][x] > grid[y][x + 1]){
// printf("%d:(%d,%d)は右より大きい\n", spread, y, x);
grid[y][x + 1]++;
spread++;
pour(x + 1, y);
}
}
if(x - 1 >= 0){
if(grid[y][x] > grid[y][x - 1]){
// printf("%d:(%d,%d)は左より大きい\n", spread, y, x);
grid[y][x - 1]++;
spread++;
pour(x - 1, y);
}
}
if(y + 1 < h){
if(grid[y][x] > grid[y + 1][x]){
// printf("%d:(%d,%d)は下より大きい\n", spread, y, x);
grid[y + 1][x]++;
spread++;
pour(x, y + 1);
}
}
if(y - 1 >= 0){
if(grid[y][x] > grid[y - 1][x]){
// printf("%d:(%d,%d)は上より大きい\n", spread, y, x);
grid[y - 1][x]++;
spread++;
pour(x, y - 1);
}
}
}
int main(){
int p;
int i, j;
int x, y;
while(1){
scanf("%d %d %d", &w, &h, &p);
if(w == 0 && h == 0 && p == 0)break;
for(i = 0; i < h; i++){
for(j = 0; j < w; j++){
scanf("%d", &grid[i][j]);
}
}
if(p){
spread = 1;
while(p--){
scanf("%d %d", &x, &y);
pour(x, y);
}
}else{
spread = 0;
}
printf("%d\n", spread);
}
return 0;
}
Submission Info
Submission Time
2012-05-26 18:56:59+0900
Task
C - 流れ
User
wada811
Language
C (GCC 4.4.7)
Score
0
Code Size
1783 Byte
Status
WA
Exec Time
22 ms
Memory
788 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:58: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
./Main.c:62: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
./Main.c:68: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
Judge Result
Set Name
all
Score / Max Score
0 / 100
Status
Set Name
Test Cases
all
00_sample, 01_Teuchi00, 10_Random_00, 10_Random_01, 10_Random_02, 10_Random_03, 10_Random_04, 10_Random_05, 10_Random_06, 10_Random_07, 10_Random_08, 10_Random_09
Case Name
Status
Exec Time
Memory
00_sample
AC
21 ms
672 KB
01_Teuchi00
WA
21 ms
668 KB
10_Random_00
WA
22 ms
680 KB
10_Random_01
WA
19 ms
652 KB
10_Random_02
WA
19 ms
664 KB
10_Random_03
WA
22 ms
656 KB
10_Random_04
WA
19 ms
672 KB
10_Random_05
WA
21 ms
668 KB
10_Random_06
WA
20 ms
660 KB
10_Random_07
WA
19 ms
664 KB
10_Random_08
WA
21 ms
788 KB
10_Random_09
WA
19 ms
656 KB