結果
| 問題 | No.30 たこやき工場 |
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-03-30 01:40:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 893 bytes |
| コンパイル時間 | 745 ms |
| コンパイル使用メモリ | 68,484 KB |
| 実行使用メモリ | 10,144 KB |
| 最終ジャッジ日時 | 2024-07-03 22:50:03 |
| 合計ジャッジ時間 | 7,202 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 1 -- * 6 |
ソースコード
#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