結果

問題 No.30 たこやき工場
ユーザー finefine
提出日時 2017-02-27 19:58:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4,901 ms / 5,000 ms
コード長 567 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 168,748 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 05:19:02
合計ジャッジ時間 7,338 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 4,901 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;

int ans[100];
vector<P> g[100];

void dfs(int cur, ll cost) {
	if (g[cur].empty()) {
		ans[cur] += cost;
		return;
	}
	for (P p : g[cur]) {
		dfs(p.second, cost * p.first);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int p, r;
		ll q;
		cin >> p >> q >> r;
		p--;
		r--;
		g[r].emplace_back(q, p);
	}
	dfs(n - 1, 1);
	for (int i = 0; i < n - 1; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}
0