結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-16 21:08:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,116 bytes |
| コンパイル時間 | 2,650 ms |
| コンパイル使用メモリ | 208,984 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-05-16 21:08:08 |
| 合計ジャッジ時間 | 3,550 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
vector<int> topolo(vector<vector<pair<int,long long>>> &Graph){
int siz = Graph.size();
vector<int> ret,inV(siz);
for(auto u : Graph) for(auto [to,w] : u) inV.at(to)++;
queue<int> Q;
for(int i=siz-1; i<siz; i++) if(inV.at(i) == 0) Q.push(i);
while(Q.size()){
int pos = Q.front(); Q.pop();
ret.push_back(pos);
for(auto [to,w] : Graph.at(pos)){
inV.at(to)--;
if(inV.at(to) == 0) Q.push(to);
}
}
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,M; cin >> N >> M;
vector<vector<pair<int,long long>>> Graph(N),rev(N);
for(int i=0; i<M; i++){
int a,b,c; cin >> a >> b >> c; a--; c--;
Graph.at(c).push_back({a,b});
}
auto topo = topolo(Graph);
vector<long long> need(N); need.at(N-1) = 1;
for(auto pos : topo) for(auto [to,w] : Graph.at(pos)) need.at(to) += need.at(pos)*w;
for(int i=0; i<N-1; i++){
if(Graph.at(i).size()) cout << "0\n";
else cout << need.at(i) << "\n";
}
}