답안 #934837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
934837 2024-02-28T05:08:51 Z irmuun Toll (BOI17_toll) C++17
100 / 100
1975 ms 9668 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll k,n,m,O;
    cin>>k>>n>>m>>O;
    vector<pair<ll,ll>>adj[n];
    for(ll i=1;i<=m;i++){
        ll a,b,t;
        cin>>a>>b>>t;
        adj[a].pb({b,t});
    }
    ll dp[n];
    for(ll i=1;i<=O;i++){
        ll a,b;
        cin>>a>>b;
        fill(dp,dp+b+1,1e18);
        dp[a]=0;
        for(ll j=a;j<b;j++){
            for(auto [y,t]:adj[j]){
                dp[y]=min(dp[y],dp[j]+t);
            }
        }
        if(dp[b]==1e18){
            cout<<-1<<"\n";
        }
        else{
            cout<<dp[b]<<"\n";
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 718 ms 4552 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 701 ms 4484 KB Output is correct
9 Correct 717 ms 4628 KB Output is correct
10 Correct 224 ms 2368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1370 ms 6376 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 20 ms 864 KB Output is correct
8 Correct 20 ms 636 KB Output is correct
9 Correct 974 ms 4700 KB Output is correct
10 Correct 1975 ms 8496 KB Output is correct
11 Correct 1402 ms 6376 KB Output is correct
12 Correct 1780 ms 5212 KB Output is correct
13 Correct 528 ms 8696 KB Output is correct
14 Correct 357 ms 5444 KB Output is correct
15 Correct 398 ms 4600 KB Output is correct
16 Correct 417 ms 4692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 21 ms 4184 KB Output is correct
11 Correct 32 ms 5968 KB Output is correct
12 Correct 48 ms 8008 KB Output is correct
13 Correct 49 ms 8784 KB Output is correct
14 Correct 41 ms 6980 KB Output is correct
15 Correct 28 ms 4440 KB Output is correct
16 Correct 26 ms 4572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 21 ms 4184 KB Output is correct
11 Correct 32 ms 5968 KB Output is correct
12 Correct 48 ms 8008 KB Output is correct
13 Correct 49 ms 8784 KB Output is correct
14 Correct 41 ms 6980 KB Output is correct
15 Correct 28 ms 4440 KB Output is correct
16 Correct 26 ms 4572 KB Output is correct
17 Correct 375 ms 5976 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 5 ms 348 KB Output is correct
24 Correct 6 ms 604 KB Output is correct
25 Correct 9 ms 860 KB Output is correct
26 Correct 7 ms 600 KB Output is correct
27 Correct 220 ms 4408 KB Output is correct
28 Correct 462 ms 8020 KB Output is correct
29 Correct 419 ms 8608 KB Output is correct
30 Correct 443 ms 7508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 718 ms 4552 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 701 ms 4484 KB Output is correct
9 Correct 717 ms 4628 KB Output is correct
10 Correct 224 ms 2368 KB Output is correct
11 Correct 1370 ms 6376 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 20 ms 864 KB Output is correct
18 Correct 20 ms 636 KB Output is correct
19 Correct 974 ms 4700 KB Output is correct
20 Correct 1975 ms 8496 KB Output is correct
21 Correct 1402 ms 6376 KB Output is correct
22 Correct 1780 ms 5212 KB Output is correct
23 Correct 528 ms 8696 KB Output is correct
24 Correct 357 ms 5444 KB Output is correct
25 Correct 398 ms 4600 KB Output is correct
26 Correct 417 ms 4692 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 21 ms 4184 KB Output is correct
37 Correct 32 ms 5968 KB Output is correct
38 Correct 48 ms 8008 KB Output is correct
39 Correct 49 ms 8784 KB Output is correct
40 Correct 41 ms 6980 KB Output is correct
41 Correct 28 ms 4440 KB Output is correct
42 Correct 26 ms 4572 KB Output is correct
43 Correct 375 ms 5976 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 456 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 5 ms 348 KB Output is correct
50 Correct 6 ms 604 KB Output is correct
51 Correct 9 ms 860 KB Output is correct
52 Correct 7 ms 600 KB Output is correct
53 Correct 220 ms 4408 KB Output is correct
54 Correct 462 ms 8020 KB Output is correct
55 Correct 419 ms 8608 KB Output is correct
56 Correct 443 ms 7508 KB Output is correct
57 Correct 1590 ms 9668 KB Output is correct
58 Correct 700 ms 4476 KB Output is correct
59 Correct 998 ms 6320 KB Output is correct