結果

問題 No.30 たこやき工場
ユーザー snrnsidysnrnsidy
提出日時 2021-05-10 03:24:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 2,345 ms
コンパイル使用メモリ 206,984 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 11:06:57
合計ジャッジ時間 3,323 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int n, m, p, q, r;
vector <pair<int,int>> adj[101];
int indegree[101];
int indegree2[101];
long long int dist[101];
int arr[101];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> p >> q >> r;
		adj[r].push_back(make_pair(p, q));
		indegree[p]++;
		indegree2[r]++;
	}

	queue <int> que;
	dist[n] = 1;
	que.push(n);

	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		for (auto it : adj[now])
		{
			int next = it.first;
			int cost = it.second;
			dist[next] += (cost * dist[now]);
			indegree[next]--;
			if (indegree[next] == 0)
			{
				que.push(next);
			}
		}
	}

	for (int i = 1; i < n; i++)
	{
		if (indegree2[i] == 0)
		{
			cout << dist[i] << '\n';
		}
		else
		{
			cout << 0 << '\n';
		}
	}
	return 0;
}
0