結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー PulmnPulmn
提出日時 2017-03-24 22:42:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,064 bytes
コンパイル時間 814 ms
コンパイル使用メモリ 100,800 KB
実行使用メモリ 8,688 KB
最終ジャッジ日時 2023-09-20 01:47:34
合計ジャッジ時間 2,108 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 6 ms
4,380 KB
testcase_03 AC 7 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 7 ms
5,060 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 16 ms
8,688 KB
testcase_09 AC 17 ms
8,684 KB
testcase_10 AC 14 ms
7,176 KB
testcase_11 AC 12 ms
6,912 KB
testcase_12 AC 15 ms
7,720 KB
testcase_13 WA -
testcase_14 AC 12 ms
5,476 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 8 ms
4,908 KB
testcase_19 WA -
testcase_20 AC 6 ms
4,560 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 9 ms
5,516 KB
testcase_25 AC 9 ms
5,228 KB
testcase_26 AC 10 ms
5,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

const int e=101;

class Graph{
	private:
	int V;
	vvp List;
	public:
	Graph(int v){
		V=v;
		List=vvp(v);
	}
	void add_edge(int s,int t,int c){
		List[s].push_back(P(t,c));
	}
	int DIJ(int s,int t){
		priority_queue<P> que;
		vi d(V,inf);
		d[s]=0;
		que.push(P(0,s));
		while(!que.empty()){
			P p=que.top();
			que.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(int i=0;i<List[v].size();i++){
				int F=List[v][i].first,S=List[v][i].second;
				if(d[F]>d[v]+S){
					d[F]=d[v]+S;
					que.push(P(-d[F],F));
				}
			}
		}
		return d[t];
	}
};

int gx,gy,n,f;

int main(){
	cin>>gx>>gy>>n>>f;
	Graph g(e*e);
	for(int i=0;i<n;i++){
		int x,y,c;
		cin>>x>>y>>c;
		for(int j=0;j<e;j++) for(int k=0;k<e;k++){
			int cx=j+x,cy=k+y;
			if(cx>=0&&cx<e&&cy>=0&&cy<=e) g.add_edge(j*e+k,cx*e+cy,c);
		}
	}
	for(int i=0;i<e;i++) for(int j=0;j<e;j++){
		if(i!=e-1) g.add_edge(i*e+j,(i+1)*e+j,f);
		if(j!=e-1) g.add_edge(i*e+j,i*e+j+1,f);
	}
	cout<<g.DIJ(0,gx*e+gy)<<endl;
}
0