結果
| 問題 | No.30 たこやき工場 |
| コンテスト | |
| ユーザー |
motxx
|
| 提出日時 | 2014-09-26 01:06:23 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 935 bytes |
| 記録 | |
| コンパイル時間 | 1,914 ms |
| コンパイル使用メモリ | 168,100 KB |
| 実行使用メモリ | 814,600 KB |
| 最終ジャッジ日時 | 2024-12-30 06:28:46 |
| 合計ジャッジ時間 | 7,447 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 RE * 3 MLE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
struct Edge
{
int dst;
int cost;
Edge(int d, int c) : dst(d), cost(c) {}
};
vector<Edge> G[110];
typedef pair<int, int> Pii;
int N, M;
vector<int> get(int st)
{
vector<int> ans(N-1);
queue<Pii> Q;
Q.push(Pii(st, 1));
while(!Q.empty()) {
int pos = Q.front().first;
int cost = Q.front().second; Q.pop();
ans[pos] += cost;
rep(i, G[pos].size()) {
Q.push(Pii(G[pos][i].dst, G[pos][i].cost*cost));
}
}
return ans;
}
int main() {
cin >> N >> M;
bool isntLast[110] = {};
rep(i, M) {
int p, q, r;
cin >> p >> q >> r; p --, r --;
G[r].push_back(Edge(p, q));
isntLast[r] = 1;
}
vector<int> ans(get(N-1));
rep(i, N-1) {
if(isntLast[i]) cout << 0 << endl;
else cout << ans[i] << endl;
}
return 0;
}
motxx