結果

問題 No.867 避難経路
ユーザー IKyoproIKyopro
提出日時 2019-08-16 23:25:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,323 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 66,940 KB
実行使用メモリ 348,508 KB
最終ジャッジ日時 2023-10-24 05:41:43
合計ジャッジ時間 59,706 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,116 KB
testcase_01 AC 3 ms
5,000 KB
testcase_02 AC 3 ms
5,184 KB
testcase_03 AC 2 ms
5,056 KB
testcase_04 AC 3 ms
5,120 KB
testcase_05 AC 2 ms
5,056 KB
testcase_06 AC 2 ms
5,056 KB
testcase_07 AC 2 ms
5,056 KB
testcase_08 AC 2 ms
5,000 KB
testcase_09 AC 2 ms
5,000 KB
testcase_10 AC 2 ms
5,000 KB
testcase_11 AC 2 ms
5,056 KB
testcase_12 AC 2 ms
5,000 KB
testcase_13 AC 3 ms
5,000 KB
testcase_14 AC 3 ms
5,000 KB
testcase_15 AC 3,661 ms
348,428 KB
testcase_16 AC 3,833 ms
348,456 KB
testcase_17 AC 3,707 ms
348,456 KB
testcase_18 AC 3,654 ms
348,456 KB
testcase_19 AC 3,680 ms
348,456 KB
testcase_20 AC 3,803 ms
348,456 KB
testcase_21 AC 3,896 ms
348,432 KB
testcase_22 AC 3,762 ms
348,456 KB
testcase_23 AC 3,775 ms
348,456 KB
testcase_24 AC 3,899 ms
348,456 KB
testcase_25 AC 3,864 ms
348,456 KB
testcase_26 AC 3,917 ms
348,456 KB
testcase_27 AC 3,823 ms
348,456 KB
testcase_28 AC 3,888 ms
348,456 KB
testcase_29 AC 3,901 ms
348,456 KB
testcase_30 AC 3,633 ms
348,456 KB
testcase_31 AC 3,557 ms
348,456 KB
testcase_32 AC 3,682 ms
348,456 KB
testcase_33 WA -
testcase_34 AC 3,506 ms
348,208 KB
testcase_35 AC 3,585 ms
348,208 KB
testcase_36 AC 3,461 ms
346,152 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 3 ms
9,792 KB
testcase_42 AC 4 ms
13,888 KB
testcase_43 AC 4 ms
13,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ll dp[251][251][701] = {};
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,700);
    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