답안 #955343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955343 2024-03-30T07:46:30 Z doducanh Tracks in the Snow (BOI13_tracks) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define fi first
#define se second
int dx[4]={0,1,-1,0};
int dy[4]={-1,0,0,1};
const int maxn=4005;
string s[maxn];
int d[maxn][maxn];
int n,m;
 check(int x,int y)
{
    return ((x>-1)&&(x<n)&&(y>-1)&&(y<m)&&(s[x][y]!='.')&&(d[x][y]==0));
}
main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>s[i];
    d[0][0]=1;
    deque<ii>dq;
    int ans=0;
    dq.push_back({0,0});
    while(dq.size()){
        ii c=dq.front();
        dq.pop_front();
        ans=max(ans,d[c.fi][c.se]);
        for(int i=0;i<4;i++){
            int x=c.fi+dx[i];
            int y=c.se+dy[i];
            if(check(x,y)){
                if(s[c.fi][c.se]!=s[x][y]){
                    d[x][y]=d[c.fi][c.se]+1;
                    dq.push_back({x,y});
                }
                else{
                    d[x][y]=d[c.fi][c.se];
                    dq.push_front({x,y});
                }
            }
        }
    }
    cout<<ans;
}

Compilation message

tracks.cpp:12:2: error: ISO C++ forbids declaration of 'check' with no type [-fpermissive]
   12 |  check(int x,int y)
      |  ^~~~~
tracks.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main()
      | ^~~~