結果

問題 No.1 道のショートカット
ユーザー ameolpameolp
提出日時 2014-11-17 00:18:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,414 bytes
コンパイル時間 1,055 ms
コンパイル使用メモリ 96,216 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 11:46:15
合計ジャッジ時間 2,435 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 10000000;

vector<vector<int> > wy, wm;
vector<int> ry, rm;
int n, c, v;

void dfs(int x, int y, int m)
{
	if(y > c || m > rm[x]) {
		return;
	}

	ry[x] = y;
	rm[x] = m;

	for(int i = 0; i < n; i++) {
		if(wy[x][i] != -1) {
			dfs(i, y + wy[x][i], m + wm[x][i]);
		}
	}
}

int main()
{	
	cin >> n >> c >> v;
	wy = wm = vector<vector<int> >(n, vector<int>(n, -1));
	ry = rm = vector<int>(n, INF);
	
	vector<int> ss(v), ts(v), ys(v), ms(v);
	for(int i = 0; i < v; i++) {
		cin >> ss[i];
	}
	for(int i = 0; i < v; i++) {
		cin >> ts[i];
	}
	for(int i = 0; i < v; i++) {
		cin >> ys[i];
	}
	for(int i = 0; i < v; i++) {
		cin >> ms[i];
	}

	for(int i = 0; i < v; i++) {
		wy[ss[i]-1][ts[i]-1] = wy[ts[i]-1][ss[i]-1] = ys[i];
		wm[ss[i]-1][ts[i]-1] = wm[ts[i]-1][ss[i]-1] = ms[i];
	}

	dfs(0, 0, 0);

	if(rm[n-1] == INF) {
		cout << -1 << endl;
	} else {
		cout << rm[n-1] << endl;
	}

	return 0;
}
0