結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
akun0716
|
| 提出日時 | 2020-10-07 22:39:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,817 bytes |
| コンパイル時間 | 1,280 ms |
| コンパイル使用メモリ | 105,844 KB |
| 実行使用メモリ | 14,244 KB |
| 最終ジャッジ日時 | 2024-07-20 04:18:07 |
| 合計ジャッジ時間 | 2,464 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 WA * 6 |
コンパイルメッセージ
main.cpp:37: warning: "LLINF" redefined
37 | #define LLINF 922337203685477580
|
main.cpp:31: note: this is the location of the previous definition
31 | #define LLINF 9223372036854775807
|
ソースコード
#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;
}
akun0716