제출 #1255316

#제출 시각아이디문제언어결과실행 시간메모리
1255316Mer123haba456Tracks in the Snow (BOI13_tracks)C++20
82.50 / 100
2107 ms269256 KiB
#include <bits/stdc++.h> using namespace std; #define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define N lli(4005) #define MOD lli(1e9 + 7) #define heps(v) v.begin(), v.end() typedef long long int lli; typedef vector<lli> vlli; typedef pair<lli, lli> plli; typedef vector<plli> vplli; typedef pair<lli, plli> pplli; typedef vector<pplli> vpplli; lli n,m,k,q,t; vlli vect; lli diz[N][N]; lli vis[4002][4002]; vplli yonler = {{0,1},{0,-1}, {1,0}, {-1,0}}; int main() { fast_io cin >> n >> m; for(lli i = 1;i<=n;i++) for(lli j = 1;j<=m;j++){ char c; cin >> c; if(c == 'F') diz[i][j] = 1; else if(c == 'R') diz[i][j] = 2; } priority_queue<pplli> Q; Q.push({-1, {1,1}}); lli enb = 0; while(!(Q.empty())){ pplli su = Q.top(); Q.pop(); if(vis[su.second.first][su.second.second]) continue; vis[su.second.first][su.second.second] = 1; enb = max(enb, -su.first); for(plli yon : yonler){ lli x = su.second.first + yon.first; lli y = su.second.second + yon.second; if(vis[x][y]) continue; if(!diz[x][y]) continue; if(diz[x][y] == diz[su.second.first][su.second.second]) Q.push({su.first, {x,y}}); else Q.push({su.first - 1, {x,y}}); } } cout << enb << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...