結果

問題 No.867 避難経路
ユーザー IKyoproIKyopro
提出日時 2019-08-17 00:44:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,323 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 66,984 KB
実行使用メモリ 299,232 KB
最終ジャッジ日時 2023-10-24 14:21:28
合計ジャッジ時間 48,732 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
15,924 KB
testcase_01 AC 4 ms
15,924 KB
testcase_02 AC 4 ms
15,924 KB
testcase_03 AC 4 ms
15,924 KB
testcase_04 AC 4 ms
15,924 KB
testcase_05 AC 4 ms
15,924 KB
testcase_06 AC 4 ms
15,924 KB
testcase_07 AC 4 ms
15,924 KB
testcase_08 AC 4 ms
15,924 KB
testcase_09 AC 5 ms
15,924 KB
testcase_10 AC 5 ms
15,924 KB
testcase_11 AC 5 ms
15,924 KB
testcase_12 AC 4 ms
15,924 KB
testcase_13 AC 4 ms
15,924 KB
testcase_14 AC 4 ms
15,924 KB
testcase_15 AC 4,374 ms
299,124 KB
testcase_16 AC 4,033 ms
299,136 KB
testcase_17 AC 3,993 ms
299,132 KB
testcase_18 AC 3,907 ms
299,136 KB
testcase_19 AC 3,809 ms
299,160 KB
testcase_20 AC 4,190 ms
299,136 KB
testcase_21 AC 3,943 ms
299,180 KB
testcase_22 AC 4,084 ms
299,188 KB
testcase_23 AC 4,055 ms
299,188 KB
testcase_24 AC 4,233 ms
299,192 KB
testcase_25 AC 4,052 ms
299,192 KB
testcase_26 AC 3,785 ms
299,192 KB
testcase_27 AC 3,635 ms
299,216 KB
testcase_28 AC 3,730 ms
299,232 KB
testcase_29 AC 3,868 ms
299,232 KB
testcase_30 AC 3,527 ms
299,232 KB
testcase_31 AC 3,387 ms
299,232 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 3,466 ms
297,492 KB
testcase_35 AC 3,284 ms
297,492 KB
testcase_36 AC 3,357 ms
294,032 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 3 ms
7,780 KB
testcase_42 AC 3 ms
11,876 KB
testcase_43 AC 3 ms
11,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll dp[251][251][601] = {};
ll inf = 1e18;
int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};

int main(){
    int H,W,gx,gy;
    cin >> H >> W >> gx >> gy;
    int K = min(H*W,600);
    vector<vector<ll>> A(H+1,vector<ll>(W+1,0));
    for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
        cin >> A[i][j];
        for(int k=1;k<=K;k++) dp[i][j][k] = inf;
    }
    dp[gx][gy][1] = A[gx][gy];
    auto in = [&](int x,int y){
        return 1<=x && x<=H && 1<=y && y<=W;
    };
    for(int k=1;k<K;k++) for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
        for(int l=0;l<4;l++){
            int nx = i+dx[l],ny = j+dy[l];
            if(!in(nx,ny)) continue;
            dp[nx][ny][k+1] = min(dp[nx][ny][k+1],dp[i][j][k]+A[nx][ny]);
        }
    }
    int Q;
    cin >> Q;
/*     vector<ll> ans(Q,0);
    struct query{
        int id,x,y;
        ll level;
        bool operator<(const query& right)const{
            return level<right.level;
        }
    };
    vector<vector<ll>> A(H+1,vector<ll>(W+1,0));
    vector<query> qs;*/
    for(int q=0;q<Q;q++){
        int x,y; ll k;
        cin >> x >> y >> k;
        ll ans = inf;
        for(ll i=1;i<=K;i++) ans = min(ans,dp[x][y][i]+i*k*k);
        cout << ans << endl;
    }
}
0