結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-03-24 22:40:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,203 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 172,240 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 01:40:22
合計ジャッジ時間 3,539 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 3 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




typedef long long ll;
int GX, GY, N, F;
ll X[60], Y[60], C[60];
//-----------------------------------------------------------------------------------
#define INF 1LL<<60
ll dst[1010][1010];
bool vis[1010][1010];
ll sol() {
	rep(i, 0, 101) rep(j, 0, 101) dst[i][j] = INF;
	priority_queue<pair<ll, int>> que;
	que.push({0LL, 0});
	dst[0][0] = 0;

	while (!que.empty()) {
		auto q = que.top(); que.pop();

		int x = q.second % 1010;
		int y = q.second / 1010;
		ll 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;

			ll 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;
}
0