結果

問題 No.30 たこやき工場
コンテスト
ユーザー nanophoto12
提出日時 2016-02-21 00:38:37
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3,740 ms / 5,000 ms
コード長 1,091 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 469 ms
コンパイル使用メモリ 98,328 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-10 18:31:00
合計ジャッジ時間 5,240 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <queue>
#include <algorithm>
#include <vector>
#include <set>
#include <iostream>
#include <numeric>
#include <tuple>
#include <cmath>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define ALL(container) (container).begin(), (container).end()

pii shifts[] = {{1,0},{0,1},{-1,0},{0,-1}};

bool fs[501][501];

vector<pii> t[101];
ll external[101];

ll buy[101];

void solve(int index, ll count)
{
    if(t[index].size() == 0)
    {
        buy[index] += count;
        return;
    }
    for(const auto& r : t[index])
    {
        solve(r.first, r.second * count);
    }
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    REP(i, m)
    {
        ll p, q, r;
        cin >> p >> q >> r;
        t[r].emplace_back(p,q);
    }
    fill(external, external+101, -1);
    fill(buy, buy+101, 0);
    solve(n, 1);
    for(int i = 1;i < n;i++)
    {
        cout << buy[i] << endl;
    }
    return 0;
}
0