結果

問題 No.30 たこやき工場
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-24 03:02:06
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 759 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 68,180 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 05:18:26
合計ジャッジ時間 6,431 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 memo[110];

void dfs(int u, int num){
	if(G[u].size() == 0){
		memo[u] += num;
		return;
	}

	for(auto v : G[u]){// u -> v.first
		dfs(v.first, v.second * num);
	}
	return;
}

int main(void){
	cin >> n >> m;
	rep(i, m){
		int p, q, r; cin >> p >> q >> r;
		p--; r--;
		//r -> p
		G[r].push_back(make_pair(p, q));
	}
	rep(i, 110) memo[i] = 0;

	dfs(n - 1, 1);
	rep(i, n - 1){
		printf("%d\n", memo[i]);
	}
	return 0;
}
0