답안 #994894

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994894 2024-06-08T08:15:00 Z Aiperiii Toll (BOI17_toll) C++14
100 / 100
2418 ms 9696 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,k,m,q;
    cin>>k>>n>>m>>q;
    vector <pair <int,int> > g[n];
    while(m--){
        int u,v,x;
        cin>>u>>v>>x;
        g[u].pb({v,x});
    }
    while(q--){
        int u,v;
        cin>>u>>v;
        vector <int> dp(n,1e18);
        dp[u]=0;
        for(int i=u;i<v;i++){
            for(auto x : g[i]){
                dp[x.ff]=min(dp[x.ff],dp[i]+x.ss);
            }
        }
        if(dp[v]==1e18)dp[v]=-1;
        cout<<dp[v]<<"\n";
    }
}
/*
 5 14 5 5
 0 5 9
 5 12 10
 0 7 7
 7 12 8
 4 7 10
 0 12
 0 5
 0 7
 7 12
 0 13
*/




# 결과 실행 시간 메모리 Grader output
1 Correct 778 ms 4540 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 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 344 KB Output is correct
8 Correct 757 ms 4480 KB Output is correct
9 Correct 753 ms 4308 KB Output is correct
10 Correct 341 ms 2112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1571 ms 6100 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 388 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 29 ms 600 KB Output is correct
8 Correct 21 ms 652 KB Output is correct
9 Correct 1096 ms 4444 KB Output is correct
10 Correct 2418 ms 8240 KB Output is correct
11 Correct 1806 ms 6320 KB Output is correct
12 Correct 1827 ms 5328 KB Output is correct
13 Correct 580 ms 8296 KB Output is correct
14 Correct 411 ms 5220 KB Output is correct
15 Correct 411 ms 4456 KB Output is correct
16 Correct 404 ms 4460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 604 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 468 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 20 ms 4308 KB Output is correct
11 Correct 37 ms 5980 KB Output is correct
12 Correct 49 ms 8028 KB Output is correct
13 Correct 54 ms 8788 KB Output is correct
14 Correct 41 ms 6992 KB Output is correct
15 Correct 26 ms 4456 KB Output is correct
16 Correct 26 ms 4464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 604 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 468 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 20 ms 4308 KB Output is correct
11 Correct 37 ms 5980 KB Output is correct
12 Correct 49 ms 8028 KB Output is correct
13 Correct 54 ms 8788 KB Output is correct
14 Correct 41 ms 6992 KB Output is correct
15 Correct 26 ms 4456 KB Output is correct
16 Correct 26 ms 4464 KB Output is correct
17 Correct 364 ms 6092 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 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 5 ms 552 KB Output is correct
24 Correct 6 ms 604 KB Output is correct
25 Correct 9 ms 600 KB Output is correct
26 Correct 8 ms 604 KB Output is correct
27 Correct 238 ms 4308 KB Output is correct
28 Correct 461 ms 8152 KB Output is correct
29 Correct 484 ms 8800 KB Output is correct
30 Correct 448 ms 7000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 778 ms 4540 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 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 344 KB Output is correct
8 Correct 757 ms 4480 KB Output is correct
9 Correct 753 ms 4308 KB Output is correct
10 Correct 341 ms 2112 KB Output is correct
11 Correct 1571 ms 6100 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 388 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 29 ms 600 KB Output is correct
18 Correct 21 ms 652 KB Output is correct
19 Correct 1096 ms 4444 KB Output is correct
20 Correct 2418 ms 8240 KB Output is correct
21 Correct 1806 ms 6320 KB Output is correct
22 Correct 1827 ms 5328 KB Output is correct
23 Correct 580 ms 8296 KB Output is correct
24 Correct 411 ms 5220 KB Output is correct
25 Correct 411 ms 4456 KB Output is correct
26 Correct 404 ms 4460 KB Output is correct
27 Correct 0 ms 344 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 604 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 468 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 20 ms 4308 KB Output is correct
37 Correct 37 ms 5980 KB Output is correct
38 Correct 49 ms 8028 KB Output is correct
39 Correct 54 ms 8788 KB Output is correct
40 Correct 41 ms 6992 KB Output is correct
41 Correct 26 ms 4456 KB Output is correct
42 Correct 26 ms 4464 KB Output is correct
43 Correct 364 ms 6092 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 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 5 ms 552 KB Output is correct
50 Correct 6 ms 604 KB Output is correct
51 Correct 9 ms 600 KB Output is correct
52 Correct 8 ms 604 KB Output is correct
53 Correct 238 ms 4308 KB Output is correct
54 Correct 461 ms 8152 KB Output is correct
55 Correct 484 ms 8800 KB Output is correct
56 Correct 448 ms 7000 KB Output is correct
57 Correct 1830 ms 9696 KB Output is correct
58 Correct 725 ms 4440 KB Output is correct
59 Correct 1170 ms 6332 KB Output is correct