Submission #00034
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <bits/stdc++.h> using namespace std; unsigned long long way[101][101]; unsigned long long need[101]; unsigned long long used[101]; int N, M; void DFS( int n, unsigned long long num) { int cnt = 0; for ( int i = 0; i < N-1; i++){ if (i == n) continue ; if (way[n][i] > 0){ DFS(i, way[n][i]*num); cnt++; } } if (cnt == 0) need[n] += num; } int main() { cin >> N >> M; for ( int i = 0; i < M; i++){ int P, Q, R; cin >> P >> Q >> R; --P, --R; way[R][P] = Q; used[R]++; } for ( int i = 0; i < N-1; i++){ if (way[N-1][i] > 0) DFS(i, way[N-1][i]); } for ( int i = 0; i < N-1; i++){ cout << need[i] << endl; } } |
ステータス
項目 | データ |
---|---|
問題 | 0002 - PRO製造機 |
ユーザー名 | ukuku09 |
投稿日時 | 2015-09-16 17:44:56 |
言語 | C++11 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 722 Byte |
最大実行時間 | 24 ms |
最大メモリ使用量 | 700 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 80 / 80 | * |
2 | G☆O☆D☆O☆K☆U | 20 / 20 | 10.txt |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |
---|---|---|---|---|---|
1.txt | AC | 23 ms | 476 KB |
1
|
|
2.txt | AC | 23 ms | 552 KB |
1
|
|
3.txt | AC | 21 ms | 528 KB |
1
|
|
4.txt | AC | 24 ms | 496 KB |
1
|
|
5.txt | AC | 24 ms | 464 KB |
1
|
|
6.txt | AC | 16 ms | 436 KB |
1
|
|
7.txt | AC | 20 ms | 408 KB |
1
|
|
8.txt | AC | 21 ms | 500 KB |
1
|
|
9.txt | AC | 22 ms | 464 KB |
1
|
|
10.txt | AC | 21 ms | 452 KB |
1
|
2
|
error1.txt | AC | 23 ms | 556 KB |
1
|
|
system_test1.txt | AC | 20 ms | 400 KB |
1
|
|
system_test2.txt | AC | 21 ms | 372 KB |
1
|
|
system_test3.txt | AC | 16 ms | 464 KB |
1
|
|
system_test4.txt | AC | 19 ms | 520 KB |
1
|
|
system_test5.txt | AC | 22 ms | 700 KB |
1
|