Submission #1020049

#TimeUsernameProblemLanguageResultExecution timeMemory
10200497againTracks in the Snow (BOI13_tracks)C++17
0 / 100
2096 ms1048576 KiB
#include <bits/stdc++.h> #define int long long #define f first #define s second #define all(x) x.begin(),x.end() #define FAST ios::sync_with_stdio(0);cout.tie(0);cin.tie(0) using namespace std ; void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} const int N = 2e5 , MOD = 1e9+7 ; int xis[4]{1 , -1 , 0 , 0} , yis[4]{0 , 0 , 1 , -1} ; int n , m ; vector <int> v[N] ; bool inside(int x , int y) { return (x < n && x > -1 && y < m && y > -1) ; } void slv() { cin >> n >> m ; char a[n][m] ; for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < m ; j++) cin >> a[i][j] ; int depth[n][m]{0} ; deque <pair <int , int>> q ; q.push_back({0 , 0}) ; depth[0][0] = 0 ; int mx = 1 ; while(!q.empty()) { pair <int , int> t = q.front() ; q.pop_back() ; mx = max(mx , depth[t.f][t.s]) ; for(int i = 0 ; i < 4 ; i++) { int x = t.f + xis[i] , y = t.s = yis[i] ; if(inside(x , y) && depth[x][y] == 0) { if(a[x][y] == a[t.f][t.s]) { depth[x][y] = depth[t.f][t.s] ; q.push_back({x , y}) ; } else { depth[x][y] = depth[t.f][t.s] + 1 ; q.push_front({x , y}) ; } } } } cout << mx ; } main() { //FAST ; slv() ; }

Compilation message (stderr)

tracks.cpp:66:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   66 | main()
      | ^~~~
tracks.cpp: In function 'void setIO(std::string)':
tracks.cpp:10:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:10:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...