제출 #1091844

#제출 시각아이디문제언어결과실행 시간메모리
1091844Jakub_WozniakTracks in the Snow (BOI13_tracks)C++14
93.44 / 100
2067 ms76260 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); cout.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++) { cin >> SA; 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-i*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: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++)
      |                         ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...