제출 #591323

#제출 시각아이디문제언어결과실행 시간메모리
591323imObscureTracks in the Snow (BOI13_tracks)C++17
100 / 100
955 ms222124 KiB
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() using pi = pair<int,int>; #define f first #define s second #define mp make_pair #define re(i,n) for(int i=0;i<n;i++) #define reb(i,n) for(int i=n-1;i>=0;i--) #define test int t;cin>>t;while(t--) void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); if (sz(name)) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } signed main(){ setIO(); int n,m; cin>>n>>m; vector<string> grid(n); vector<vi> vis(n,vi(m)); re(i,n)cin>>grid[i]; deque<pair<int,pair<int,int>>> q; q.pb({1,{0,0}}); int r[4]={1,-1,0,0}; int c[4]={0,0,-1,1}; int ans=0; while(sz(q)){ pair<int,pair<int,int>> cur=q.front(); q.pop_front(); ans=max(ans,cur.f); vis[cur.s.f][cur.s.s]=1; for(int i=0;i<4;i++){ int x=cur.s.f+r[i],y=cur.s.s+c[i]; if(x>=0 && x<n && y>=0 && y<m && !vis[x][y] && grid[x][y]!='.'){ if(grid[x][y]!=grid[cur.s.f][cur.s.s]){ q.push_back({cur.f+1,{x,y}}); } else q.push_front({cur.f,{x,y}}); } } } cout<<ans; }

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

tracks.cpp: In function 'void setIO(std::string)':
tracks.cpp:23:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   freopen((name + ".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:24:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   freopen((name + ".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...