史蒂夫玩跑酷
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
int n, m, k;
signed main(){
cin >> n >> m >> k;
vector<vector<char>> a(n + 1, vector<char>(m + 1));
vector<vector<bool>> state(n + 1, vector<bool>(m + 1, 0));
int stx, sty, edx, edy;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
cin >> a[i][j];
if(a[i][j] == 's') {stx = i; sty = j;}
if(a[i][j] == 't') {edx = i; edy = j;}
}
}
priority_queue<array<int, 4>, vector<array<int, 4>>, greater<array<int, 4>>> pq;
pq.push({0, 0, stx, sty});
while(pq.size()){
auto [ans1, ans2, x, y] = pq.top(); pq.pop();
if(x == edx && y == edy){
cout << ans1 << " " << ans2 << endl; return 0;
}
if(state[x][y]) continue;
state[x][y] = 1;
for(int i = x - k; i <= x + k; ++i){
for(int j = y - k; j <= y + k; ++j){
if(i < 1 || j < 1 || i > n || j > m || state[i][j]) continue;
if((i - x) * (i - x) + (j - y) * (j - y) <= k * k){
if(a[i][j] == '1' || a[i][j] == 't'){
pq.push({ans1, ans2 + 1, i, j});
}else pq.push({ans1 + 1, ans2 + 1, i, j});
}
}
}
}
return 0;
}