結果
| 問題 | No.30 たこやき工場 |
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-03-24 19:43:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,104 bytes |
| 記録 | |
| コンパイル時間 | 479 ms |
| コンパイル使用メモリ | 50,532 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-21 05:19:27 |
| 合計ジャッジ時間 | 1,216 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d %d", &N, &M);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d %d %d", &p, &q, &r);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
// 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