結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
Kutimoti_T
|
| 提出日時 | 2017-12-18 22:08:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 697 bytes |
| コンパイル時間 | 1,050 ms |
| コンパイル使用メモリ | 66,896 KB |
| 実行使用メモリ | 814,880 KB |
| 最終ジャッジ日時 | 2024-12-16 00:53:11 |
| 合計ジャッジ時間 | 5,825 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 MLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d %d %d",&p,&q,&r);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>
#define FOR(i,s,e) for(int i = (s);i <= (e);i++)
using namespace std;
int N;
int M;
struct edge
{
int to;
int cost;
};
vector<edge> V[110];
int dp[110];
int main()
{
cin >> N;
cin >> M;
int p,q,r;
FOR(i,0,M-1)
{
scanf("%d %d %d",&p,&q,&r);
V[r].push_back({p,q});
}
queue<int> que;
que.push(N);
dp[N] = 1;
while(!que.empty())
{
int x = que.front();
que.pop();
int siz = static_cast<int>(V[x].size());
FOR(i,0,siz - 1)
{
const edge& e = V[x][i];
dp[e.to] += dp[x] * e.cost;
que.push(e.to);
}
if(siz != 0) dp[x] = 0;
}
FOR(i,1,N -1)
{
printf("%d\n",dp[i]);
}
return 0;
}
Kutimoti_T