-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjongman_1_9.24.cpp
More file actions
57 lines (57 loc) · 1.18 KB
/
jongman_1_9.24.cpp
File metadata and controls
57 lines (57 loc) · 1.18 KB
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
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <limits>
using namespace std;
int len[50];
int prefer[50];
double T[50][50];
double cache[5][50][4];
int main(){
int C;
cin >> C;
cout << fixed;
cout.precision(8);
for(int test=0;test<C;++test){
int n,k,m;
cin >> n >> k >> m;
for(int i=0;i<n;++i){
cin >> len[i];
}
for(int i=0;i<n;++i){
for(int j=0;j<n;++j){
cin >> T[i][j];
}
}
for(int i=0;i<m;++i){
cin >> prefer[i];
}
memset(cache,0.0,sizeof(cache));
for(int time=0;time<len[0];++time){
cache[time][0][time] = 1.0;
}
for(int time=len[0];time<=k;++time){
for(int current=0;current<n;++current){
for(int duration = 0;duration<len[current];++duration){
double& ret = cache[time%5][current][duration];
ret = 0.0;
for(int before=0;before<n;++before){
if(time>=duration+1) ret += cache[(time-duration-1)%5][before][len[before]-1] * T[before][current];
}
}
}
}
for(int i=0;i<m;++i){
double total = 0;
for(int j=0;j<len[prefer[i]];++j){
total += cache[k%5][prefer[i]][j];
}
cout << total << " ";
}
cout << endl;
}
return 0;
}