結果
問題 |
No.30 たこやき工場
|
ユーザー |
![]() |
提出日時 | 2016-07-02 01:24:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,053 bytes |
コンパイル時間 | 900 ms |
コンパイル使用メモリ | 83,740 KB |
実行使用メモリ | 814,220 KB |
最終ジャッジ日時 | 2024-10-12 01:53:12 |
合計ジャッジ時間 | 4,271 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 MLE * 1 -- * 6 |
ソースコード
#include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <ctime> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <iostream> #include <algorithm> #include <functional> #include <numeric> #include <string> #define N_MAX 100 #define M_MAX 1500 using namespace std; typedef pair<int, long long> P; int N, M; vector<P> g[N_MAX + 1]; long long buy[N_MAX]; int main(void) { cin >> N >> M; for (int i = 0; i < M; i++) { long long p, q, r; cin >> p >> q >> r; g[r].push_back(P(p, q)); } queue<P> q; q.push(P(N, 1)); while (!q.empty()) { int x, need; tie(x, need) = q.front(); q.pop(); if (g[x].size() == 0) { buy[x] += need; } else { for (int i = 0; i < g[x].size(); i++) { q.push(P(g[x][i].first, g[x][i].second * need)); } } } for (int i = 1; i < N; i++) { printf("%lld\n", buy[i]); } return 0; }