제출 #681095

#제출 시각아이디문제언어결과실행 시간메모리
681095MasterTasterTracks 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:109:1: error: extended character   is not valid in an identifier
  109 |  
      | ^
tracks.cpp: In function 'int main()':
tracks.cpp:107:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  107 | for (int i=0; i<nww.size(); i++) { nw2.pb(nww[i]); cnt++; }
      |               ~^~~~~~~~~~~
tracks.cpp:109:1: error: ' ' was not declared in this scope
  109 |  
      | ^