結果
問題 | No.1364 [Renaming] Road to Cherry from Zelkova |
ユーザー | 👑 Nachia |
提出日時 | 2021-01-22 23:28:40 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,002 bytes |
コンパイル時間 | 2,071 ms |
コンパイル使用メモリ | 207,400 KB |
実行使用メモリ | 15,524 KB |
最終ジャッジ日時 | 2023-08-27 22:50:31 |
合計ジャッジ時間 | 7,614 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,896 KB |
testcase_01 | AC | 2 ms
5,756 KB |
testcase_02 | AC | 2 ms
5,824 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 27 ms
7,860 KB |
testcase_24 | AC | 28 ms
7,388 KB |
testcase_25 | AC | 70 ms
10,376 KB |
testcase_26 | AC | 111 ms
12,884 KB |
testcase_27 | AC | 83 ms
12,136 KB |
testcase_28 | AC | 47 ms
9,284 KB |
testcase_29 | AC | 77 ms
12,080 KB |
testcase_30 | AC | 50 ms
9,320 KB |
testcase_31 | AC | 33 ms
8,176 KB |
testcase_32 | AC | 62 ms
11,340 KB |
testcase_33 | AC | 101 ms
12,620 KB |
testcase_34 | AC | 93 ms
11,508 KB |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 63 ms
10,084 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | AC | 41 ms
11,040 KB |
testcase_44 | AC | 34 ms
11,512 KB |
testcase_45 | AC | 39 ms
9,300 KB |
testcase_46 | AC | 6 ms
8,316 KB |
testcase_47 | AC | 3 ms
5,920 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const ULL M=1000000007; struct Edge{ int to; ULL d,t; }; int N,n; vector<Edge> E[100001]; int I[100001]; vector<int> Ord; ULL dpc[100001]; ULL dp[100001]; int main() { scanf("%d%d",&N,&n); N++; rep(i,N) I[i]=0; rep(i,n){ int u,v,d,t; scanf("%d%d%d%d",&u,&v,&d,&t); E[u].push_back({v,(ULL)d,(ULL)t}); I[v]++; } { queue<int> Q; rep(i,N) if(I[i]==0) Q.push(i); vector<int> Iin(N); while(Q.size()){ int p=Q.front(); Q.pop(); Ord.push_back(p); Iin[p]=1; for(auto& e:E[p]) if((--I[e.to])==0) Q.push(e.to); } if(Iin[0]==0 || Iin[N-1]==0){ printf("INF\n"); return 0; } } rep(i,N) dp[i]=dpc[i]=0; dpc[0]=1; for(int p:Ord){ for(Edge e:E[p]){ dpc[e.to] = (dpc[e.to]+dpc[p]*e.t)%M; dp[e.to] = (dp[e.to]+(dp[p]+e.d)*e.t)%M; } } printf("%llu\n",dp[N-1]); return 0; }