結果
| 問題 | No.496 ワープクリスタル (給料日前編) |
| コンテスト | |
| ユーザー |
はまやんはまやん
|
| 提出日時 | 2017-03-24 22:34:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,185 bytes |
| 記録 | |
| コンパイル時間 | 1,667 ms |
| コンパイル使用メモリ | 173,120 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 03:06:58 |
| 合計ジャッジ時間 | 2,388 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 WA * 6 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
int GX, GY, N, F;
int X[60], Y[60], C[60];
//-----------------------------------------------------------------------------------
#define INF INT_MAX/2
int dst[1010][1010];
bool vis[1010][1010];
int sol() {
rep(i, 0, 101) rep(j, 0, 101) dst[i][j] = INF;
priority_queue<pair<int, int>> que;
que.push({0, 0});
dst[0][0] = 0;
while (!que.empty()) {
auto q = que.top(); que.pop();
int x = q.second % 1010;
int y = q.second / 1010;
int c = -q.first;
if (y == GY && x == GX) return c;
if (vis[y][x]) continue;
vis[y][x] = true;
rep(i, 0, N) {
int yy = y + Y[i];
int xx = x + X[i];
if (GY < yy) continue;
if (GX < xx) continue;
if (vis[yy][xx]) continue;
int nc = c + C[i];
if (nc < dst[yy][xx]) {
dst[yy][xx] = nc;
que.push({ -nc, yy * 1010 + xx });
}
}
}
return -1;
}
//-----------------------------------------------------------------------------------
int main() {
cin >> GX >> GY >> N >> F;
rep(i, 0, N) cin >> X[i] >> Y[i] >> C[i];
X[N] = 0; Y[N] = 1; C[N] = F; N++;
X[N] = 1; Y[N] = 0; C[N] = F; N++;
cout << sol() << endl;
}
はまやんはまやん