結果

問題 No.30 たこやき工場
ユーザー kenken714kenken714
提出日時 2019-04-20 19:00:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,475 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 91,704 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 20:19:47
合計ジャッジ時間 1,385 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n, m;
struct edge { ll to, cost; };
vector<ll> in(110);
vector<edge> g[110];
int main() {
	cin >> n >> m;
	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		c--;
		g[a].push_back({ c,b });
		in[c]++;
	}
	REP(i, n - 1) {
		bool used[110] = {};
		vector<ll> nin(110);
		vector<ll> ans(n);
		ans[i] = 1;
		queue<ll> que;
		que.push(i);
		while (!que.empty()) {
			ll now = que.front();
			used[now] = true;
			que.pop();
			REP(k, g[now].size()) {
				nin[g[now][k].to]++;
				if (!used[g[now][k].to])que.push(g[now][k].to);
			}
		}
		que.push(i);
		while (!que.empty()) {
			ll now = que.front();
			que.pop();
			REP(k, g[now].size()) {
				ans[g[now][k].to] += ans[now] * g[now][k].cost;
				nin[g[now][k].to]--;
				if(nin[g[now][k].to] == 0)que.push(g[now][k].to);
			}
		}
		if (in[i] != 0)cout << 0 << endl;
		else cout << ans[n - 1] << endl;
	}
}


0