# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
14270 |
2015-05-09T13:29:55 Z |
tjdals1865 |
토마토 (KOI13_tomato) |
C++ |
|
1000 ms |
8912 KB |
#include <stdio.h>
#include <stdlib.h>
int n,m,i,j,tomato[1001][1001],day=0,tomatocnt=0,rec[1001][1001],empty;
void input(){
scanf("%d %d",&m,&n);
for(i=0;i<n;i++){
for(j=0;j<m;j++){
scanf("%d",&tomato[i][j]);
if(tomato[i][j]==-1) empty++;
if(tomato[i][j]==1) tomatocnt++;
}
}
}
void process(){
while(day<=(n*m-empty)){
if(tomatocnt==n*m-empty) break;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if(tomato[i][j]==1 && rec[i][j]!=(-1)*day-1){
if(tomato[i-1][j]==0 && i-1>=0){
tomatocnt++;
tomato[i-1][j]=1;
rec[i-1][j]=(-1)*day-1;
}
if(tomato[i][j-1]==0 && j-1>=0){
tomatocnt++;
tomato[i][j-1]=1;
rec[i][j-1]=(-1)*day-1;
}
if(tomato[i+1][j]==0 && i+1<n){
tomatocnt++;
tomato[i+1][j]=1;
rec[i+1][j]=(-1)*day-1;
}
if(tomato[i][j+1]==0 && j+1<m){
tomatocnt++;
tomato[i][j+1]=1;
rec[i][j+1]=(-1)*day-1;
}
}
}
}
day++;
}
}
void output(){
if(day==(n*m-empty+1)) printf("-1");
else printf("%d",day);
}
int main(void){
input();
process();
output();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8912 KB |
Output is correct |
2 |
Correct |
0 ms |
8912 KB |
Output is correct |
3 |
Correct |
0 ms |
8912 KB |
Output is correct |
4 |
Correct |
0 ms |
8912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8912 KB |
Output is correct |
2 |
Correct |
0 ms |
8912 KB |
Output is correct |
3 |
Correct |
0 ms |
8912 KB |
Output is correct |
4 |
Correct |
0 ms |
8912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8912 KB |
Output is correct |
2 |
Correct |
3 ms |
8912 KB |
Output is correct |
3 |
Correct |
0 ms |
8912 KB |
Output is correct |
4 |
Correct |
7 ms |
8912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
8912 KB |
Output is correct |
2 |
Correct |
8 ms |
8912 KB |
Output is correct |
3 |
Correct |
0 ms |
8912 KB |
Output is correct |
4 |
Correct |
0 ms |
8912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
8912 KB |
Output is correct |
2 |
Correct |
0 ms |
8912 KB |
Output is correct |
3 |
Correct |
11 ms |
8912 KB |
Output is correct |
4 |
Correct |
16 ms |
8912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8912 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
8912 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
264 ms |
8912 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
8908 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
230 ms |
8912 KB |
Output is correct |
2 |
Correct |
159 ms |
8912 KB |
Output is correct |
3 |
Correct |
14 ms |
8912 KB |
Output is correct |
4 |
Correct |
56 ms |
8912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
217 ms |
8912 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
8908 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
647 ms |
8912 KB |
Output is correct |
2 |
Correct |
390 ms |
8912 KB |
Output is correct |
3 |
Execution timed out |
1000 ms |
8908 KB |
Program timed out |
4 |
Halted |
0 ms |
0 KB |
- |