結果
| 問題 | No.30 たこやき工場 |
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-03-24 19:43:14 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,104 bytes |
| 記録 | |
| コンパイル時間 | 383 ms |
| コンパイル使用メモリ | 72,008 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-27 22:23:18 |
| 合計ジャッジ時間 | 1,373 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
// Wrongri-La Shower
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <utility>
#include <queue>
typedef long long ll;
typedef std::pair<int,int> P;
int N, M;
std::vector<P> G[101];
int count[101][101], degree[101], enter[101];
int main(){
scanf("%d %d", &N, &M);
for(int i=0;i<M;i++){
int p, q, r;
scanf("%d %d %d", &p, &q, &r);
G[p].emplace_back(r, q);
++degree[r];
}
std::queue<int> queue;
for(int i=1;i<N;i++){
if(degree[i] == 0){
queue.push(i);
count[i][i] = 1;
}
}
while(!queue.empty()){
int u = queue.front(); queue.pop();
for(const auto& e : G[u]){
if(enter[e.first] >= degree[e.first]){continue;}
for(int i=1;i<=N;i++){
count[e.first][i] += count[u][i] * e.second;
}
++enter[e.first];
if(enter[e.first] == degree[e.first]){
queue.push(e.first);
}
}
}
for(int i=1;i<N;i++){
printf("%d\n", count[N][i]);
}
}
tottoripaper