結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー akun0716akun0716
提出日時 2020-10-07 22:39:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,817 bytes
コンパイル時間 2,165 ms
コンパイル使用メモリ 104,344 KB
実行使用メモリ 14,104 KB
最終ジャッジ日時 2023-09-27 10:08:52
合計ジャッジ時間 2,898 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 9 ms
4,620 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 47 ms
14,028 KB
testcase_09 AC 46 ms
14,104 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 10 ms
4,648 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 10 ms
4,848 KB
testcase_19 WA -
testcase_20 AC 8 ms
4,396 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 36 ms
7,972 KB
testcase_24 AC 34 ms
7,784 KB
testcase_25 AC 31 ms
7,224 KB
testcase_26 AC 35 ms
7,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:37: 警告: "LLINF" が再定義されました
   37 | #define LLINF 922337203685477580
      | 
main.cpp:31: 備考: ここが以前の宣言がある位置です
   31 | #define LLINF 9223372036854775807
      | 

ソースコード

diff #

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

struct edge { int to, cost; };
#define LLINF 922337203685477580

int N, gx, gy;
vector<vector<edge> > G;
VI d;

void dikstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> >que;
	REP(i, d.size())d[i] = LLINF;
	d[s] = 0;
	que.push(pii(0, s));
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		REP(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}
}

bool is_in(int x, int y) {
	return (x > gx || y > gy);//枠の外
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int F; cin >> gx >> gy >> N >> F;
	vector<pair<pii, int> > A(N);
	REP(i, N)cin >> A[i].first.first >> A[i].first.second >> A[i].second;
	
	map<pii, int> mp;
	int tmp = 0;
	eREP(i, gx)eREP(j, gy)mp[pii(i, j)] = tmp++;
	G.resize(tmp);
	d.resize(tmp);
	//cout << tmp << endl;
	eREP(i, gx) {
		eREP(j, gy) {

			int from = mp[pii(i, j)];

			REP(k, N) {
				int x = A[k].first.first + i;
				int y = A[k].first.second + j;
				int c = A[k].second;

				if (is_in(x, y))continue;

				int to = mp[pii(x, y)];
				//cout << k<<" "<< from << " " << to << " " << c << endl;
				//cout << k<<" "<< from << " " << to << " " << c << endl;
				G[from].push_back((edge) { to, c });
			}

			if (!is_in(i + 1, j)) {
				int to = mp[pii(i + 1, j)];
				G[from].push_back((edge) { to, F });
			}
			if (!is_in(i, j + 1)) {
				int to = mp[pii(i, j + 1)];
				G[from].push_back((edge) { to, F });
			}

		}
	}
	dikstra(0);
	eREP(i, gx)eREP(j, gy) {
		//cout << gx << " " << gy << " " << d[mp[pii(gx, gy)]] << endl;
	}
	cout << d[mp[pii(gx, gy)]] << endl;

	return 0;
}

0