結果

問題 No.30 たこやき工場
ユーザー ren0824xemnasren0824xemnas
提出日時 2015-09-14 21:33:10
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 769 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 65,324 KB
実行使用メモリ 7,708 KB
最終ジャッジ日時 2023-09-26 11:53:54
合計ジャッジ時間 7,427 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;

ll dfs(int now);
int n,m;
vector<P> data[101];
bool used[101];
bool flg[101];
ll cou[101];

int main(){
	cin >> n >> m;
	memset(flg,true,n+2);
	for(int i=0;i<m;i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--; c--;
		data[a].push_back(P(c,b));
		flg[c] = false;
	}
	memset(cou,0,n+1);
	for(int i=0;i<n;i++){
		if(flg[i]){
			cou[i]=dfs(i);
		}
	}
	for(int i=0;i<n-1;i++){
		cout << cou[i] << endl;
	}
}

ll dfs(int now){
	if(now == n-1) return 1;
	ll res = 0;
	int len = data[now].size();
	for(int i=0;i<len;i++){
		P p = data[now][i];
		int next = p.first;
		int num = p.second;
		res += dfs(next) *  num;
	}
	return res;
}
0