Submission #680735

#TimeUsernameProblemLanguageResultExecution timeMemory
680735MasterTasterTracks in the Snow (BOI13_tracks)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <string> #include <vector> #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> nw; 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]) { nw.pb({i, j}); cnt++; } ress=1; int which=3-a[1][1]; //cout<<cnt<<endl; while (cnt<n*m) { vector<pii> nww; nww.clear(); for (auto p:nw) { 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); nw.clear(); for (int i=0; i<nww.size(); i++) { nw.pb(nww[i]); cnt++; } ress++; which=3-which; } cout<<ress; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:72:28: error: 'assert' was not declared in this scope
   72 |         if (nww.size()==0) assert(0);
      |                            ^~~~~~
tracks.cpp:4:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    3 | #include <vector>
  +++ |+#include <cassert>
    4 | 
tracks.cpp:76:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         for (int i=0; i<nww.size(); i++) { nw.pb(nww[i]); cnt++; }
      |                       ~^~~~~~~~~~~