結果
| 問題 | No.30 たこやき工場 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-15 15:37:25 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 5,000 ms |
| コード長 | 667 bytes |
| 記録 | |
| コンパイル時間 | 1,910 ms |
| コンパイル使用メモリ | 175,084 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-01-15 15:37:28 |
| 合計ジャッジ時間 | 2,940 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <iostream>
#include <map>
#include <vector>
struct Qi{uint32_t Q;uint32_t i;};
std::vector<std::vector<Qi>> in;
int N,M;
std::vector<uint32_t> S,cntout,seen;
void childs(int i){
for(auto e:in[i]){cntout[e.i]++;if(!seen[e.i]){seen[e.i]=1;childs(e.i);}}
}
void calc(int i){
for(auto e:in[i]){S[e.i]+=S[i]*e.Q;if(--cntout[e.i]==0)calc(e.i);}
if(!in[i].empty())S[i]=0;
}
int main(){
std::cin>>N>>M;
in.resize(N);
S.resize(N);
seen.resize(N);
cntout.resize(N);
for (int i = 0; i < M; i++) {
uint32_t P,Q,R;std::cin>>P>>Q>>R;
in[R-1].push_back({Q,P-1});
}
childs(N-1);
S[N-1]=1;
calc(N-1);
for(int i=0;i<N-1;i++)std::cout<<S[i]<<"\n";return 0;
}