제출 #1091841

#제출 시각아이디문제언어결과실행 시간메모리
1091841Jakub_WozniakTracks in the Snow (BOI13_tracks)C++14
0 / 100
2 ms912 KiB
#include <bits/stdc++.h> #include <stdio.h> using namespace std; const int maxn = 4009; typedef long long ll; int N , M; string s[maxn]; string SA; int a , b , c; vector <pair<int,int>> R; bool vis[maxn][maxn]; int MAXI = 0; void pr() { R.push_back({-1,0}); R.push_back({1,0}); R.push_back({0,1}); R.push_back({0,-1}); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> M; for(int i = 0 ; i <= M+1 ; i++)SA.push_back( '.'); s[0] = SA; s[N+1] = SA; pr(); for(int i = 1 ; i <= N ;i++) { scanf("%s", &SA); SA.pop_back(); s[i] = '.'; s[i] += SA; s[i].push_back('.'); } priority_queue <pair<int,int>> q; pair<int,int> DS; q.push({-1,1*maxn+1}); int i , j; vis[1][1] = 1; while(!q.empty()) { DS = q.top(); c = -DS.first; i = DS.second/maxn; j = DS.second%maxn; q.pop(); MAXI = max(MAXI , c); for(int k = 0 ; k < R.size() ; k++) { a = i+R[k].first; b = j+R[k].second; if(s[a][b] == '.' || vis[a][b])continue; vis[a][b] = 1; if(s[a][b] == s[i][j]){ q.push({-c,a*maxn+b});} else {q.push({-(c+1),a*maxn+b});} } } cout << MAXI << '\n'; return 0; }

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

tracks.cpp: In function 'int main()':
tracks.cpp:35:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'std::string*' {aka 'std::__cxx11::basic_string<char>*'} [-Wformat=]
   35 |         scanf("%s", &SA);
      |                ~^   ~~~
      |                 |   |
      |                 |   std::string* {aka std::__cxx11::basic_string<char>*}
      |                 char*
tracks.cpp:58:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         for(int k = 0 ; k < R.size() ; k++)
      |                         ~~^~~~~~~~~~
tracks.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         scanf("%s", &SA);
      |         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...