結果

問題 No.30 たこやき工場
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-24 03:26:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 824 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 67,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 23:02:14
合計ジャッジ時間 1,390 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int INF = 1e9;

int n, m;
// int p[1550], q[1550], r[1550];
vector<pair<int, int> > G[110];
int dp[110];

int dfs(int u){
	if(u == n - 1){
		return dp[u] = 1;
	}
	if(dp[u]) return dp[u];

	int ret = 0;
	for(auto v : G[u]){// u -> v.first
		ret += dfs(v.first) * v.second;
	}
	return dp[u] = ret;
}

int main(void){
	cin >> n >> m;
	rep(i, m){
		int p, q, r; cin >> p >> q >> r;
		p--; r--;
		//p -> r
		G[p].push_back(make_pair(r, q));
	}
	rep(i, 110) dp[i] = 0;
	
	rep(i, n - 1){
		if(G[i].size() == 0){
			printf("0\n");
		}else{
			printf("%d\n", dfs(i));
		}
	}
	return 0;
}
0