제출 #681090

#제출 시각아이디문제언어결과실행 시간메모리
681090MasterTasterTracks in the Snow (BOI13_tracks)C++14
컴파일 에러
0 ms0 KiB
#include <iostream>

#include <string>

#include <vector>

#include <assert.h>

 

#define MAXN 4010

#define ll long long

#define pb push_back

#define pii pair<int, int>

#define xx first

#define yy second

 

using namespace std;

 

int n, m, a[MAXN][MAXN], cnt, ress;

int x[4], y[4];

bool vis[MAXN][MAXN];

vector<pii> nw1, nw2;

 

void dfs(int i, int j)

{

//cout<<"usao "<<i<<" "<<j<<" "<<cnt<<endl;

vis[i][j]=true;

for (int k=0; k<4; k++)

{

///( out of bounds ) ( visited ) ( same )

if (/*i+x[k]<=0 || i+x[k]>n || j+y[k]<=0 || j+y[k]>m || */vis[i+x[k]][j+y[k]] || a[i+x[k]][j+y[k]]!=a[i][j]) continue;

dfs(i+x[k], j+y[k]);

}

}

 

int main() {

cin>>n>>m;

 

x[0]=-1; x[1]=0; x[2]=1; x[3]=0; ///up right down left

y[0]=0; y[1]=1; y[2]=0; y[3]=-1; ///up right down left

 

for (int i=0; i<=max(n, m); i++) vis[i][0]=vis[0][i]=vis[i][m+1]=vis[n+1][i]=true;

for (int i=1; i<=n; i++)

{

string s; cin>>s;

for (int j=1; j<=m; j++)

{

if (s[j-1]=='.') { a[i][j]=0; cnt++; }

else if (s[j-1]=='R') a[i][j]=1;

else a[i][j]=2;

}

}

//for (int i=1; i<=n; i++) { for (int j=1; j<=m; j++) cout<<a[i][j]<<" "; cout<<endl; }

 

dfs(1, 1);

for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) if (vis[i][j]) { nw2.pb({i, j}); cnt++; }
ress=1;
nw1.clear();

 

int which=3-a[1][1];

//cout<<cnt<<endl;

while (cnt<n*m)

{

vector<pii> nww;

nww.clear();

 

for (auto p:nw1)

{

for (int i=0; i<4; i++)

{

if (!vis[p.xx+x[i]][p.yy+y[i]] && a[p.xx+x[i]][p.yy+y[i]]==which)

{

vis[p.xx+x[i]][p.yy+y[i]]=true;

nww.pb({p.xx+x[i], p.yy+y[i]});

}

}

}

for (auto p:nw2)

{

for (int i=0; i<4; i++)

{

if (!vis[p.xx+x[i]][p.yy+y[i]] && a[p.xx+x[i]][p.yy+y[i]]==which)

{

vis[p.xx+x[i]][p.yy+y[i]]=true;

nww.pb({p.xx+x[i], p.yy+y[i]});

}

}
}


if (nww.size()==0) assert(0);

nw1=nw2;
nw2.clear();
for (int i=0; i<nww.size(); i++) { nw2.pb(nww[i]); cnt++; }

 

ress++;

which=3-which;

}

cout<<ress;

}

    

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp:9:1: error: extended character   is not valid in an identifier
    9 |  
      | ^
tracks.cpp:23:1: error: extended character   is not valid in an identifier
   23 |  
      | ^
tracks.cpp:27:1: error: extended character   is not valid in an identifier
   27 |  
      | ^
tracks.cpp:37:1: error: extended character   is not valid in an identifier
   37 |  
      | ^
tracks.cpp:61:1: error: extended character   is not valid in an identifier
   61 |  
      | ^
tracks.cpp:67:1: error: extended character   is not valid in an identifier
   67 |  
      | ^
tracks.cpp:73:1: error: extended character   is not valid in an identifier
   73 |  
      | ^
tracks.cpp:99:1: error: extended character   is not valid in an identifier
   99 |  
      | ^
tracks.cpp:107:1: error: extended character   is not valid in an identifier
  107 |  
      | ^
tracks.cpp:121:1: error: extended character   is not valid in an identifier
  121 |  
      | ^
tracks.cpp:173:1: error: extended character   is not valid in an identifier
  173 |  
      | ^
tracks.cpp:9:1: error: '\U000000a0' does not name a type
    9 |  
      | ^
tracks.cpp:27:1: error: '\U000000a0' does not name a type
   27 |  
      | ^
tracks.cpp:35:1: error: 'vector' does not name a type
   35 | vector<pii> nw1, nw2;
      | ^~~~~~
tracks.cpp:37:1: error: '\U000000a0' does not name a type
   37 |  
      | ^
tracks.cpp:61:1: error: '\U000000a0' does not name a type
   61 |  
      | ^