# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1117 |
2013-06-26T05:48:38 Z |
jiws829 |
토마토 (KOI13_tomato) |
C++ |
|
0 ms |
4992 KB |
#include<stdio.h>
int n,m;
int p[1001][1001];
int check()
{
int i,j;
int r=0,a=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if(p[i][j]==1) r=1;
if(p[i][j]==0) a=1;
}
}
if(a==1 && r==1) return 0;
if(a==0 && r==1) return 1;
if(r==0) return -1;
}
void make()
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if(p[i][j]==1)
{
p[i-1][j]=p[i+1][j]=p[i][j-1]=p[i][j+1]=2;
}
}
}
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%d %d",&m,&n);
int i,j,k,r;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
scanf("%d",&p[i][j]);
}
}
for(k=0;;k++)
{
r=check();
if(r) break;
make();
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if(p[i][j]==2)
{
p[i][j]=1;
}
}
}
if(r==1) break;
}
if(r==-1) printf("-1");
else printf("%d\n",k);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
4992 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |