Submission #00019


ソースコード

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
#include<bits/stdc++.h>
#define F first
#define S second
#define INF (1<<30)
using namespace std;
typedef pair<long long,long long> P;
vector<P> resipi[100];
map<long long,long long> mem;
void dfs(long long now,long long hosii);
main(){
long long n,m,p,q,r;
cin>>n>>m;
for(int i=0;i<m;i++){
cin>>p>>q>>r;
resipi[r].push_back(P(p,q));
}
dfs(n,1);
for(int i=1;i<=n-1;i++){
cout<<mem[(long long)i]<<endl;
}
}
void dfs(long long now,long long hosii){
/*
if(mem[now]!=0){
return;
}
*/
for(int i=0;i<resipi[now].size();i++){
long long zairyou=resipi[now][i].F;
if(resipi[zairyou].size()==0){
mem[zairyou]+=hosii*resipi[now][i].S;
}
else{
dfs(zairyou,hosii*resipi[now][i].S);
}
}
return;
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
1.txt AC 13 ms 476 KB
1
2.txt AC 18 ms 552 KB
1
3.txt AC 12 ms 532 KB
1
4.txt AC 20 ms 636 KB
1
5.txt AC 14 ms 612 KB
1
6.txt AC 15 ms 588 KB
1
7.txt AC 21 ms 696 KB
1
8.txt AC 19 ms 544 KB
1
9.txt AC 20 ms 512 KB
1
10.txt AC 18 ms 712 KB
1
2
error1.txt AC 17 ms 612 KB
1
system_test1.txt AC 14 ms 460 KB
1
system_test2.txt AC 20 ms 560 KB
1
system_test3.txt AC 20 ms 660 KB
1
system_test4.txt AC 21 ms 624 KB
1
system_test5.txt AC 14 ms 592 KB
1