結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2017-03-24 22:55:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,507 bytes |
| コンパイル時間 | 1,549 ms |
| コンパイル使用メモリ | 181,332 KB |
| 実行使用メモリ | 823,244 KB |
| 最終ジャッジ日時 | 2024-07-05 22:21:05 |
| 合計ジャッジ時間 | 5,617 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 WA * 1 MLE * 1 -- * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
#define INF 10000000
struct ST {
int x, y, c;
};
int main(){
int Gx, Gy, N, F;
cin >> Gx >> Gy >> N >> F;
vector<ST> v;
rep(i,N){
int x, y, c;
cin >> x >> y >> c;
v.push_back((ST){x,y,c});
}
vector<vector<int>> cost(Gy+1, vector<int>(Gx+1,INF));
cost[0][0] = 0;
rep(i,N){
vector<vector<int>> new_cost = cost;
rep(y,cost.size()){
rep(x,cost[y].size()){
if(cost[y][x] != INF){
if(x+v[i].x<cost[y].size() && y+v[i].y<cost.size()){
new_cost[y+v[i].y][x+v[i].x] = min(new_cost[y+v[i].y][x+v[i].x],
cost[y][x] + v[i].c);
}
}
}
}
queue<ST> que;
que.push((ST){0,0,0});
while(!que.empty()){
ST st = que.front(); que.pop();
if(st.y+1<cost.size()){
new_cost[st.y+1][st.x] = min(new_cost[st.y+1][st.x], new_cost[st.y][st.x]+F);
que.push((ST){st.x,st.y+1,0});
}
if(st.x+1<cost[st.y].size()){
new_cost[st.y][st.x+1] = min(new_cost[st.y][st.x+1], new_cost[st.y][st.x]+F);
que.push((ST){st.x+1,st.y,0});
}
}
cost = new_cost;
}
cout << cost[Gy][Gx] << endl;
return 0;
}
どらら