結果

問題 No.30 たこやき工場
ユーザー mizunomidorimizunomidori
提出日時 2016-07-02 01:24:54
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,053 bytes
コンパイル時間 868 ms
コンパイル使用メモリ 83,868 KB
実行使用メモリ 817,420 KB
最終ジャッジ日時 2024-04-20 06:45:58
合計ジャッジ時間 4,109 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0