結果
| 問題 |
No.971 いたずらっ子
|
| コンテスト | |
| ユーザー |
y61mpnl
|
| 提出日時 | 2020-01-17 22:30:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,233 bytes |
| コンパイル時間 | 1,709 ms |
| コンパイル使用メモリ | 176,504 KB |
| 実行使用メモリ | 97,920 KB |
| 最終ジャッジ日時 | 2024-06-25 21:59:36 |
| 合計ジャッジ時間 | 4,827 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 14 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
struct P {
ll x, y, bs, dist;
};
int main(){
ll h, w; scanf("%lld %lld", &h, &w);
vector<vector<ll>> fig(h, vector<ll>(w));
for(ll i=0; i<h; i++){
string s; cin>>s;
for(ll j=0; j<w; j++) fig[i][j] = (s[j]=='k');
}
ll dx[] = {0, 1, 0, -1};
ll dy[] = {1, 0, -1, 0};
vector<vector<ll>> ans(h, vector<ll>(w, 1e11)), used(h, vector<ll>(w, 0));
queue<P> que;
P p = {0, 0, -1, 0};
que.push(p);
while(!que.empty()){
p = que.front(); que.pop();
used[p.x][p.y] = 1;
if(fig[p.x][p.y]) p.dist += p.dist-p.bs;
if(ans[p.x][p.y]<=p.dist) continue;
ans[p.x][p.y] = p.dist;
for(ll i=0; i<4; i++){
ll tx = p.x-dx[i], ty = p.y-dy[i];
if(0<=tx && tx<h and 0<=ty && ty<w){
P np = {tx, ty, p.bs+fig[tx][ty], p.dist+1};
que.push(np);
}
}
}
printf("%lld\n", ans[h-1][w-1]);
return 0;
}
y61mpnl