# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
4029 | waps12b | Following Flow (kriii1_F) | C++98 | 0 ms | 1920 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int v[31][1001];
double dist[31][1001];
int cnt[31];
double dp[1000][30];
double per[1000][30];
int main(){
int n, m;scanf("%d %d",&n,&m);
for(int i=0;i<m;i++){
int a, b;
double t;
scanf("%d %d %lf",&a,&b,&t);
v[a][ cnt[a] ] = b;
dist[a][ cnt[a] ] = t;
cnt[a] ++;
}
per[0][0] = 1.0;
int lmt = 500;
for(int lv=0;lv<lmt;lv++){
for(int i=0;i<n;i++){
if(!cnt[i]) continue;
double np = 1.0/ (double)cnt[i];
if( np == 0.0) continue;
for(int j=0;j<cnt[i];j++){
int dest = v[i][j];
dp[lv+1][dest] += dp[lv][i] * np + dist[i][j] * np * per[lv][i];
per[lv+1][dest] += np * per[lv][i];
}
}
}
double sum = 0.0;
for(int i=0;i<=lmt;i++){
sum += dp[i][n] ;
}
printf("%.10lf\n",sum);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |