結果

問題 No.30 たこやき工場
ユーザー hotpepsihotpepsi
提出日時 2015-03-30 01:40:20
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 893 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 69,176 KB
実行使用メモリ 7,860 KB
最終ジャッジ日時 2023-09-17 00:21:04
合計ジャッジ時間 7,210 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;

typedef long long LL;
typedef vector<LL> LLVec;

struct Node {
	LL count;
	LLVec dep_type;
	LLVec dep_count;
	Node() : count(0) { }
	void request(LL c);
};
Node nodes[100];

void Node::request(LL c) {
	if (dep_type.empty()) {
		count += c;
	} else {
		for (LL i = 0; i < dep_type.size(); ++i) {
			nodes[dep_type[i]].request(c * dep_count[i]);
		}
	}
};

int main(int argc, char *argv[]) {
	string s;
	getline(cin, s);
	int N = atoi(s.c_str());
	getline(cin, s);
	int M = atoi(s.c_str());
	for (int i = 0; i < M; ++i) {
		getline(cin, s);
		stringstream ss(s);
		int P, Q, R;
		ss >> P >> Q >> R;
		nodes[R - 1].dep_type.push_back(P - 1);
		nodes[R - 1].dep_count.push_back(Q);
	}
	nodes[N - 1].request(1);
	for (int i = 0; i < N - 1; ++i) {
		cout << nodes[i].count << endl;
	}
	return 0;
}
0