結果

問題 No.2712 Play more!
ユーザー k82bk82b
提出日時 2024-03-31 14:31:11
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,187 bytes
コンパイル時間 4,166 ms
コンパイル使用メモリ 198,008 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:31:19
合計ジャッジ時間 6,720 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 65 ms
6,676 KB
testcase_08 AC 65 ms
6,676 KB
testcase_09 AC 66 ms
6,676 KB
testcase_10 WA -
testcase_11 AC 20 ms
6,676 KB
testcase_12 AC 47 ms
6,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 55 ms
6,676 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 6 ms
6,676 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 115 ms
6,676 KB
testcase_32 AC 100 ms
6,676 KB
testcase_33 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std, core.bitop;
bool chmin(T)(ref T SE, T MI) { if (SE > MI) { SE = MI; return true; } else { return false; } }
bool chmax(T)(ref T SE, T MI) { if (SE < MI) { SE = MI; return true; } else { return false; } }
int lowerBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] < MI ? lo : hi) = mid; } return hi; }
int upperBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] > MI ? hi : lo) = mid; } return hi; }
void main() {
	int N, M;
	readf("%s %s\n", N, M);
	auto A = readln.chomp.split.to!(int[]);
	auto a = new int[M];
	auto b = new int[M];
	auto c = new int[M];
	auto G = new int[][](N, 0);
	foreach (i; 0 .. M) {
		readf("%s %s %s\n", a[i], b[i], c[i]);
		--a[i];
		--b[i];
		G[a[i]] ~= i;
	}
	auto dist = new long[N];
	dist[] = -long.max;
	dist[0] = A[0];
	foreach (i; 0 .. N * 2) {
		bool se = false;
		foreach (u; 0 .. N) {
			foreach (j; G[u]) {
				int v = u ^ a[j] ^ b[j];
				if (chmax(dist[v], dist[u] + A[v] - c[j])) {
					se = true;
				}
			}
		}
		if (i >= N && se) {
			"inf".writeln;
			return;
		}
	}
	dist[N - 1].writeln;
}
0