답안 #5916

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
5916 2014-05-23T01:43:28 Z gs12037 토마토 (KOI13_tomato) C++
컴파일 오류
0 ms 0 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 (a[i][j]==-1) break;
    }
    if(i==n+1 && j==m+1)
        printf("%d",t);
    else
        printf("-1");
}

Compilation message

tomato.cpp: In function 'int main()':
tomato.cpp:51:26: error: break statement not within loop or switch
tomato.cpp: At global scope:
tomato.cpp:53:5: error: expected unqualified-id before 'if'
tomato.cpp:55:5: error: expected unqualified-id before 'else'
tomato.cpp:57:1: error: expected declaration before '}' token
tomato.cpp: In function 'int main()':
tomato.cpp:13:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
tomato.cpp:17:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]