# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
5324 |
2014-03-23T09:03:12 Z |
baneling100 |
토마토 (KOI13_tomato) |
C++ |
|
128 ms |
9200 KB |
#include <stdio.h>
#include <queue>
using namespace std;
queue <int> q;
int m, n, a[1001][1001], d[1001][1001], ans;
int dy[4]={0,1,0,-1}, dx[4]={1,0,-1,0};
void input(void)
{
int i, j;
scanf("%d %d",&m,&n);
for(i=1 ; i<=n ; i++)
for(j=1 ; j<=m ; j++)
{
scanf("%d",&a[i][j]);
if(a[i][j]==1)
{
q.push(i);
q.push(j);
}
}
}
void process(void)
{
int i, j, y, x, ty, tx;
while(!q.empty())
{
y=q.front();
q.pop();
x=q.front();
q.pop();
for(i=0 ; i<=3 ; i++)
{
ty=y+dy[i];
tx=x+dx[i];
if(ty>=1 && ty<=n && tx>=1 && tx<=m)
if(a[ty][tx]==0)
{
a[ty][tx]=1;
d[ty][tx]=d[y][x]+1;
q.push(ty);
q.push(tx);
}
}
}
for(i=1 ; i<=n ; i++)
for(j=1 ; j<=m ; j++)
{
if(a[i][j]==0)
{
ans=-1;
return;
}
if(ans<d[i][j])
ans=d[i][j];
}
}
void output(void)
{
printf("%d",ans);
}
int main(void)
{
input();
process();
output();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9068 KB |
Output is correct |
2 |
Correct |
0 ms |
9068 KB |
Output is correct |
3 |
Correct |
0 ms |
9068 KB |
Output is correct |
4 |
Correct |
0 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9068 KB |
Output is correct |
2 |
Correct |
0 ms |
9068 KB |
Output is correct |
3 |
Correct |
0 ms |
9068 KB |
Output is correct |
4 |
Correct |
0 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9068 KB |
Output is correct |
2 |
Correct |
0 ms |
9068 KB |
Output is correct |
3 |
Correct |
0 ms |
9068 KB |
Output is correct |
4 |
Correct |
0 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
9068 KB |
Output is correct |
2 |
Correct |
4 ms |
9068 KB |
Output is correct |
3 |
Correct |
0 ms |
9068 KB |
Output is correct |
4 |
Correct |
0 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
9068 KB |
Output is correct |
2 |
Correct |
0 ms |
9068 KB |
Output is correct |
3 |
Correct |
4 ms |
9068 KB |
Output is correct |
4 |
Correct |
4 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9068 KB |
Output is correct |
2 |
Correct |
0 ms |
9068 KB |
Output is correct |
3 |
Correct |
0 ms |
9068 KB |
Output is correct |
4 |
Correct |
0 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
9068 KB |
Output is correct |
2 |
Correct |
24 ms |
9068 KB |
Output is correct |
3 |
Correct |
16 ms |
9068 KB |
Output is correct |
4 |
Correct |
12 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
9068 KB |
Output is correct |
2 |
Correct |
48 ms |
9068 KB |
Output is correct |
3 |
Correct |
8 ms |
9068 KB |
Output is correct |
4 |
Correct |
8 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
9068 KB |
Output is correct |
2 |
Correct |
88 ms |
9068 KB |
Output is correct |
3 |
Correct |
4 ms |
9068 KB |
Output is correct |
4 |
Correct |
60 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
9068 KB |
Output is correct |
2 |
Correct |
128 ms |
9200 KB |
Output is correct |
3 |
Correct |
120 ms |
9068 KB |
Output is correct |
4 |
Correct |
88 ms |
9068 KB |
Output is correct |