Submission #535529

#TimeUsernameProblemLanguageResultExecution timeMemory
535529Koful123Tracks in the Snow (BOI13_tracks)C++17
0 / 100
3 ms528 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define endl "\n" #define mod 1000000007 #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() const int N = 4005; int vis[N][N],cnt,n,m,ans; string s[N]; queue<pair<int,int>> q,tmp; void dfs(int x,int y,char c){ if(x > n || y > m || y < 0 || x < 0) return; if(vis[x][y]) return; if(!vis[x][y] && s[x][y] != c){ tmp.push({x,y}); return; } if(!vis[x][y]){ vis[x][y] = 1; cnt++; } dfs(x+1,y,c); dfs(x,y+1,c); dfs(x,y-1,c); dfs(x-1,y,c); } void solve(){ cin >> n >> m; for(int i=0;i<n;i++) cin >> s[i]; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(s[i][j] == '.'){ vis[i][j] = 1; cnt++; } } } char c = s[n-1][m-1]; q.push({n-1,m-1}); while(cnt != n*m){ while(q.size()){ auto tp = q.front(); dfs(tp.ff,tp.ss,c); q.pop(); } while(tmp.size()){ q.push(tmp.front()); tmp.pop(); } if(c == 'F') c = 'R'; else c = 'F'; ans++; } cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t = 1; //cin >> t; for(int i=1;i<=t;i++){ solve(); } return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:81:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |   freopen("in.txt","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~
tracks.cpp:82:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |   freopen("out.txt","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...