結果
| 問題 | No.30 たこやき工場 |
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-03-30 01:40:20 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 4,636 ms / 5,000 ms |
| コード長 | 893 bytes |
| 記録 | |
| コンパイル時間 | 645 ms |
| コンパイル使用メモリ | 87,984 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-03-25 05:59:49 |
| 合計ジャッジ時間 | 5,804 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#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;
}
hotpepsi