結果

問題 No.30 たこやき工場
ユーザー nanophoto12nanophoto12
提出日時 2016-02-21 00:38:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,091 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 75,740 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-23 18:44:40
合計ジャッジ時間 7,927 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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