結果

問題 No.30 たこやき工場
ユーザー Kutimoti_T
提出日時 2017-12-18 22:02:00
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
MLE  
実行時間 -
コード長 672 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 67,312 KB
実行使用メモリ 814,500 KB
最終ジャッジ日時 2024-12-16 00:52:51
合計ジャッジ時間 5,651 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#define FOR(i,s,e) for(int i = (s);i <= (e);i++)
using namespace std;

int N;
int M;

struct edge
{
	int to;
	int cost;
};

vector<edge> V[110];

int dp[110];

int main()
{
	cin >> N;
	cin >> M;
	int p,q,r;
	FOR(i,0,M-1)
	{
		cin >> p >> q >> r;
		V[r].push_back({p,q});
	}
	queue<int> que;
	que.push(N);
	dp[N] = 1;
	while(!que.empty())
	{
		int x = que.front();
		que.pop();
		int siz = static_cast<int>(V[x].size());
		FOR(i,0,siz - 1)
		{
			const edge& e = V[x][i];
			dp[e.to] += dp[x] * e.cost;
			que.push(e.to);
		}

		if(siz != 0) dp[x] = 0;
	}

	FOR(i,1,N -1)
	{
		cout << dp[i] << endl;
	}

	return 0;

}
0