Submission #5914

# Submission time Handle Problem Language Result Execution time Memory
5914 2014-05-23T01:33:12 Z gs12037 토마토 (KOI13_tomato) C++
14.4 / 16
128 ms 5356 KB
#include <stdio.h>
#include <deque>
 
using namespace std;
 
int a[1010][1010];
int x[5]={0,1,0,-1,0};
deque<int> v1,v2;
 
int main()
{
    int m,n,i,j,t=-1;
    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)
            {
                v1.push_back(i);
                v2.push_back(j);
            }
            else
                a[i][j]--;
        }
    while(v1.size()!=0)
    {
        int s=v1.size();
        for(i=0;i<s;i++)
        {
            for(int k=0;k<=3;k++)
            {
                if(a[v1.front()+x[k]][v2.front()+x[k+1]]==-1)
                {
                    a[v1.front()+x[k]][v2.front()+x[k+1]]++;
                    v1.push_back(v1.front()+x[k]);
                    v2.push_back(v2.front()+x[k+1]);
                }
            }
            v1.pop_front();
            v2.pop_front();
        }
        t++;    
    }
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            if(a[i][j]==-1)
                break;
    if(i==n+1 && j==m+1)
        printf("%d",t);
    else
        printf("-1");
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5224 KB Output is correct
2 Correct 0 ms 5224 KB Output is correct
3 Correct 0 ms 5224 KB Output is correct
4 Correct 0 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5224 KB Output is correct
2 Correct 0 ms 5224 KB Output is correct
3 Incorrect 0 ms 5224 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5224 KB Output is correct
2 Correct 0 ms 5224 KB Output is correct
3 Correct 0 ms 5224 KB Output is correct
4 Correct 0 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5224 KB Output is correct
2 Correct 4 ms 5224 KB Output is correct
3 Correct 0 ms 5224 KB Output is correct
4 Correct 0 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5224 KB Output is correct
2 Correct 0 ms 5224 KB Output is correct
3 Correct 0 ms 5224 KB Output is correct
4 Correct 0 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5224 KB Output is correct
2 Correct 4 ms 5224 KB Output is correct
3 Correct 0 ms 5224 KB Output is correct
4 Correct 4 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 5224 KB Output is correct
2 Correct 28 ms 5224 KB Output is correct
3 Correct 12 ms 5224 KB Output is correct
4 Correct 12 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 5224 KB Output is correct
2 Correct 52 ms 5224 KB Output is correct
3 Correct 4 ms 5224 KB Output is correct
4 Correct 4 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 5224 KB Output is correct
2 Correct 104 ms 5224 KB Output is correct
3 Correct 8 ms 5224 KB Output is correct
4 Correct 56 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 5224 KB Output is correct
2 Correct 124 ms 5356 KB Output is correct
3 Correct 116 ms 5224 KB Output is correct
4 Correct 80 ms 5224 KB Output is correct