제출 #928988

#제출 시각아이디문제언어결과실행 시간메모리
928988LyricallyTracks in the Snow (BOI13_tracks)C++17
0 / 100
398 ms157520 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define pb push_back #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) void file(string s){ freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } int n,m; char c[4005][4005]; int dis[4005][4005]; int dx[4]={-1,0,1,0}; int dy[4]={0,-1,0,1}; signed main(){ cin>>n>>m; rep1(i,n)scanf("%s",c[i]+1); memset(dis,-1,sizeof(dis)); dis[1][1]=0; queue<array<int,2>> q;q.push({1,1}); while(!q.empty()){ array<int,2> x=q.front();q.pop(); rep(i,4){ int tx=x[0]+dx[i],ty=x[1]+dy[i]; if(tx<1||ty<1||tx>n||ty>m)continue; if(dis[tx][ty]!=-1)continue; dis[tx][ty]=dis[x[0]][x[1]]+(c[x[0]][x[1]]!=c[tx][ty]); q.push({tx,ty}); } } cout<<dis[n][m]<<"\n"; return 0; }

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

tracks.cpp: In function 'void file(std::string)':
tracks.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  freopen((s+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:10:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  freopen((s+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp: In function 'int main()':
tracks.cpp:19:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  rep1(i,n)scanf("%s",c[i]+1);
      |           ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...