# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
2180 |
2013-07-20T07:14:41 Z |
gs13057 |
토마토 (KOI13_tomato) |
C++ |
|
1000 ms |
9056 KB |
#include<cstdio>
int n,m,r;
int d;
int t[1010][1010],tmp[1010][1010];
int main(void){
int i,j,k;
bool flag;
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
scanf("%d%d",&n,&m); r=n*m;
for(i=0;i<=n+1;i++) t[0][i]=t[m+1][i]=-1;
for(j=0;j<=m+1;j++) t[j][0]=t[j][n+1]=-1;
for(i=1;i<=m;i++) for(j=1;j<=n;j++){
scanf("%d",&t[i][j]);
if(t[i][j]!=0) r--; }
for(i=0;i<=m+1;i++) for(j=0;j<=n+1;j++)
tmp[i][j]=t[i][j];
while(1){ d++; flag=false;
for(i=1;i<=m;i++) for(j=1;j<=n;j++)
if(t[i][j]==1) for(k=0;k<4;k++)
if(tmp[i+dx[k]][j+dy[k]]==0){
tmp[i+dx[k]][j+dy[k]]=1;
flag=true; r--; }
for(i=1;i<=m;i++) for(j=1;j<=n;j++) t[i][j]=tmp[i][j];
if(!flag||r==0) break;
}
if(r) printf("-1");
else printf("%d",d);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9056 KB |
Output is correct |
2 |
Correct |
0 ms |
9056 KB |
Output is correct |
3 |
Correct |
0 ms |
9056 KB |
Output is correct |
4 |
Correct |
0 ms |
9056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9056 KB |
Output is correct |
2 |
Correct |
0 ms |
9056 KB |
Output is correct |
3 |
Correct |
0 ms |
9056 KB |
Output is correct |
4 |
Correct |
0 ms |
9056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9056 KB |
Output is correct |
2 |
Correct |
12 ms |
9056 KB |
Output is correct |
3 |
Correct |
0 ms |
9056 KB |
Output is correct |
4 |
Correct |
16 ms |
9056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
9056 KB |
Output is correct |
2 |
Correct |
8 ms |
9056 KB |
Output is correct |
3 |
Correct |
0 ms |
9056 KB |
Output is correct |
4 |
Correct |
0 ms |
9056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
9056 KB |
Output is correct |
2 |
Correct |
0 ms |
9056 KB |
Output is correct |
3 |
Correct |
16 ms |
9056 KB |
Output is correct |
4 |
Correct |
48 ms |
9056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
9056 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
9052 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
724 ms |
9056 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
9052 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
596 ms |
9056 KB |
Output is correct |
2 |
Correct |
352 ms |
9056 KB |
Output is correct |
3 |
Correct |
32 ms |
9056 KB |
Output is correct |
4 |
Correct |
132 ms |
9056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
600 ms |
9056 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
9052 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
9056 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |