Contest Duration: - (local time) (100 minutes) Back to Home

Submission #20346183

Source Code Expand

Copy
```#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, M, X, Y;
int A[101010], B[101010], T[101010], K[101010];
vector<pair<int, pair<int,int>>> E[101010];
//---------------------------------------------------------------------------------------------------
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
int vis[101010];
ll D[101010];
ll dijk() {
rep(i, 0, N) D[i] = infl;
rep(i, 0, N) vis[i] = 0;

min_priority_queue<pair<ll, int>> que;

D[X] = 0;
que.push({ 0, X });

while (!que.empty()) {
auto q = que.top(); que.pop();

ll cst = q.first;
int cu = q.second;

if (cu == Y) return D[Y];

if (vis[cu]) continue;
vis[cu] = 1;

fore(p, E[cu]) {
int to = p.first;
int T = p.second.first;
int K = p.second.second;

ll cst2 = (cst + K - 1) / K * K + T;
if (chmin(D[to], cst2)) que.push({ D[to], to });
}
}

return -1;
}
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N >> M >> X >> Y;
X--; Y--;
rep(i, 0, M) {
cin >> A[i] >> B[i] >> T[i] >> K[i];
A[i]--; B[i]--;

E[A[i]].push_back({ B[i], {T[i], K[i]} });
E[B[i]].push_back({ A[i], {T[i], K[i]} });
}

ll ans = dijk();
cout << ans << endl;
}

```

#### Submission Info

Submission Time 2021-02-20 23:16:04+0900 E - Train hamayanhamayan C++ (GCC 9.2.1) 500 2692 Byte AC 96 ms 12540 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
 AC × 4
 AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand.txt, max_01.txt, random_01.txt, random_02.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
hand.txt AC 17 ms 5928 KB
max_01.txt AC 96 ms 11888 KB
random_01.txt AC 67 ms 12540 KB
random_02.txt AC 49 ms 10624 KB
random_05.txt AC 37 ms 8656 KB
random_06.txt AC 34 ms 8972 KB
random_07.txt AC 44 ms 10844 KB
random_08.txt AC 42 ms 10896 KB
random_11.txt AC 36 ms 8640 KB
random_12.txt AC 36 ms 8724 KB
random_13.txt AC 32 ms 8336 KB
random_14.txt AC 41 ms 9276 KB
random_15.txt AC 42 ms 10272 KB
random_16.txt AC 34 ms 9016 KB
random_17.txt AC 42 ms 10564 KB
random_18.txt AC 28 ms 8632 KB
random_21.txt AC 81 ms 11848 KB
random_22.txt AC 85 ms 11812 KB
random_23.txt AC 82 ms 11812 KB
random_24.txt AC 82 ms 11792 KB
random_31.txt AC 66 ms 11568 KB
random_32.txt AC 61 ms 11608 KB
random_33.txt AC 63 ms 11640 KB
random_34.txt AC 65 ms 11704 KB
sample_01.txt AC 7 ms 5976 KB
sample_02.txt AC 8 ms 6028 KB
sample_03.txt AC 5 ms 5916 KB
sample_04.txt AC 10 ms 5868 KB