Submission #00036


ソースコード

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
42
43
44
45
46
47
48
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
ll dfs(int now);
int n,m;
vector<P> data[101];
bool used[101];
bool flg[101];
ll cou[101];
int main(){
cin >> n >> m;
memset(flg,true,n+2);
for(int i=0;i<m;i++){
int a,b,c;
cin >> a >> b >> c;
a--; c--;
data[a].push_back(P(c,b));
flg[c] = false;
}
memset(cou,0,n+1);
for(int i=0;i<n;i++){
if(flg[i]){
cou[i]=dfs(i);
}
}
for(int i=0;i<n-1;i++){
cout << cou[i] << endl;
}
}
ll dfs(int now){
if(now == n-1) return 1;
ll res = 0;
int len = data[now].size();
for(int i=0;i<len;i++){
P p = data[now][i];
int next = p.first;
int num = p.second;
res += dfs(next) * num;
}
return res;
}

ステータス

項目 データ
問題 0002 - PRO製造機
ユーザー名 ei1428
投稿日時 2015-09-16 17:45:36
言語 C++11
状態 Accepted
得点 100
ソースコード長 945 Byte
最大実行時間 27 ms
最大メモリ使用量 640 KB

セット

セット 得点 Cases
1 ALL 80 / 80 *
2 G☆O☆D☆O☆K☆U 20 / 20 10.txt

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
1.txt AC 27 ms 476 KB
1
2.txt AC 15 ms 544 KB
1
3.txt AC 18 ms 516 KB
1
4.txt AC 13 ms 496 KB
1
5.txt AC 18 ms 476 KB
1
6.txt AC 22 ms 576 KB
1
7.txt AC 21 ms 544 KB
1
8.txt AC 24 ms 520 KB
1
9.txt AC 18 ms 624 KB
1
10.txt AC 24 ms 448 KB
1
2
error1.txt AC 24 ms 588 KB
1
system_test1.txt AC 20 ms 564 KB
1
system_test2.txt AC 20 ms 540 KB
1
system_test3.txt AC 24 ms 640 KB
1
system_test4.txt AC 23 ms 616 KB
1
system_test5.txt AC 23 ms 592 KB
1