# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
783178 | 2023-07-14T16:55:45 Z | 1075508020060209tc | Toll (BOI17_toll) | C++14 | 3000 ms | 20624 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int K;int n;int m;int O; vector<pair<int,int>>e[500005]; int dis0[500005]; int dis[500005];int vis[500005]; void dijkstera(int st){ for(int i=0;i<=n;i++){ dis[i]=1e18; } dis[st]=0; for(int i=st;i<=n-1;i++){ for(int j=0;j<e[i].size();j++){ int w=e[i][j].second; int v=e[i][j].first; dis[v]=min(dis[v],dis[i]+w); } } } int ot(int v){ if(v>=1e18){ return -1; } return v; } signed main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin>>K>>n>>m>>O; for(int i=1;i<=m;i++){ int a;int b;int t; cin>>a>>b>>t; e[a].push_back({b,t}); } dijkstera(0); for(int i=0;i<=n;i++){ dis0[i]=dis[i]; } while(O--){ int a;int b; cin>>a>>b; if(a==0){ cout<<ot(dis0[b])<<endl; }else{ dijkstera(a); cout<<ot(dis[b])<<endl; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1465 ms | 15380 KB | Output is correct |
2 | Correct | 6 ms | 12072 KB | Output is correct |
3 | Correct | 6 ms | 11988 KB | Output is correct |
4 | Correct | 6 ms | 11988 KB | Output is correct |
5 | Correct | 10 ms | 12108 KB | Output is correct |
6 | Correct | 11 ms | 12116 KB | Output is correct |
7 | Correct | 11 ms | 12116 KB | Output is correct |
8 | Correct | 1552 ms | 15388 KB | Output is correct |
9 | Correct | 1725 ms | 15228 KB | Output is correct |
10 | Correct | 528 ms | 12996 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 16940 KB | Output is correct |
2 | Correct | 6 ms | 11988 KB | Output is correct |
3 | Correct | 6 ms | 11988 KB | Output is correct |
4 | Correct | 7 ms | 12068 KB | Output is correct |
5 | Correct | 6 ms | 11988 KB | Output is correct |
6 | Correct | 7 ms | 12072 KB | Output is correct |
7 | Correct | 19 ms | 12244 KB | Output is correct |
8 | Correct | 18 ms | 12216 KB | Output is correct |
9 | Correct | 29 ms | 15312 KB | Output is correct |
10 | Correct | 51 ms | 19032 KB | Output is correct |
11 | Correct | 46 ms | 17176 KB | Output is correct |
12 | Correct | 47 ms | 16200 KB | Output is correct |
13 | Correct | 58 ms | 19628 KB | Output is correct |
14 | Correct | 33 ms | 16540 KB | Output is correct |
15 | Correct | 35 ms | 15748 KB | Output is correct |
16 | Correct | 28 ms | 15692 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 11988 KB | Output is correct |
2 | Correct | 6 ms | 12068 KB | Output is correct |
3 | Correct | 6 ms | 12028 KB | Output is correct |
4 | Correct | 6 ms | 11988 KB | Output is correct |
5 | Correct | 6 ms | 12068 KB | Output is correct |
6 | Correct | 8 ms | 12116 KB | Output is correct |
7 | Correct | 8 ms | 12116 KB | Output is correct |
8 | Correct | 8 ms | 12244 KB | Output is correct |
9 | Correct | 8 ms | 12244 KB | Output is correct |
10 | Correct | 35 ms | 15132 KB | Output is correct |
11 | Correct | 55 ms | 16844 KB | Output is correct |
12 | Correct | 81 ms | 18848 KB | Output is correct |
13 | Correct | 73 ms | 19536 KB | Output is correct |
14 | Correct | 61 ms | 17740 KB | Output is correct |
15 | Correct | 46 ms | 15812 KB | Output is correct |
16 | Correct | 44 ms | 15708 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 11988 KB | Output is correct |
2 | Correct | 6 ms | 12068 KB | Output is correct |
3 | Correct | 6 ms | 12028 KB | Output is correct |
4 | Correct | 6 ms | 11988 KB | Output is correct |
5 | Correct | 6 ms | 12068 KB | Output is correct |
6 | Correct | 8 ms | 12116 KB | Output is correct |
7 | Correct | 8 ms | 12116 KB | Output is correct |
8 | Correct | 8 ms | 12244 KB | Output is correct |
9 | Correct | 8 ms | 12244 KB | Output is correct |
10 | Correct | 35 ms | 15132 KB | Output is correct |
11 | Correct | 55 ms | 16844 KB | Output is correct |
12 | Correct | 81 ms | 18848 KB | Output is correct |
13 | Correct | 73 ms | 19536 KB | Output is correct |
14 | Correct | 61 ms | 17740 KB | Output is correct |
15 | Correct | 46 ms | 15812 KB | Output is correct |
16 | Correct | 44 ms | 15708 KB | Output is correct |
17 | Correct | 641 ms | 16948 KB | Output is correct |
18 | Correct | 7 ms | 11988 KB | Output is correct |
19 | Correct | 6 ms | 12076 KB | Output is correct |
20 | Correct | 6 ms | 11972 KB | Output is correct |
21 | Correct | 6 ms | 11988 KB | Output is correct |
22 | Correct | 6 ms | 11988 KB | Output is correct |
23 | Correct | 17 ms | 12180 KB | Output is correct |
24 | Correct | 18 ms | 12144 KB | Output is correct |
25 | Correct | 30 ms | 12300 KB | Output is correct |
26 | Correct | 24 ms | 12212 KB | Output is correct |
27 | Correct | 520 ms | 15264 KB | Output is correct |
28 | Correct | 957 ms | 19128 KB | Output is correct |
29 | Correct | 907 ms | 19672 KB | Output is correct |
30 | Correct | 846 ms | 17872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1465 ms | 15380 KB | Output is correct |
2 | Correct | 6 ms | 12072 KB | Output is correct |
3 | Correct | 6 ms | 11988 KB | Output is correct |
4 | Correct | 6 ms | 11988 KB | Output is correct |
5 | Correct | 10 ms | 12108 KB | Output is correct |
6 | Correct | 11 ms | 12116 KB | Output is correct |
7 | Correct | 11 ms | 12116 KB | Output is correct |
8 | Correct | 1552 ms | 15388 KB | Output is correct |
9 | Correct | 1725 ms | 15228 KB | Output is correct |
10 | Correct | 528 ms | 12996 KB | Output is correct |
11 | Correct | 40 ms | 16940 KB | Output is correct |
12 | Correct | 6 ms | 11988 KB | Output is correct |
13 | Correct | 6 ms | 11988 KB | Output is correct |
14 | Correct | 7 ms | 12068 KB | Output is correct |
15 | Correct | 6 ms | 11988 KB | Output is correct |
16 | Correct | 7 ms | 12072 KB | Output is correct |
17 | Correct | 19 ms | 12244 KB | Output is correct |
18 | Correct | 18 ms | 12216 KB | Output is correct |
19 | Correct | 29 ms | 15312 KB | Output is correct |
20 | Correct | 51 ms | 19032 KB | Output is correct |
21 | Correct | 46 ms | 17176 KB | Output is correct |
22 | Correct | 47 ms | 16200 KB | Output is correct |
23 | Correct | 58 ms | 19628 KB | Output is correct |
24 | Correct | 33 ms | 16540 KB | Output is correct |
25 | Correct | 35 ms | 15748 KB | Output is correct |
26 | Correct | 28 ms | 15692 KB | Output is correct |
27 | Correct | 6 ms | 11988 KB | Output is correct |
28 | Correct | 6 ms | 12068 KB | Output is correct |
29 | Correct | 6 ms | 12028 KB | Output is correct |
30 | Correct | 6 ms | 11988 KB | Output is correct |
31 | Correct | 6 ms | 12068 KB | Output is correct |
32 | Correct | 8 ms | 12116 KB | Output is correct |
33 | Correct | 8 ms | 12116 KB | Output is correct |
34 | Correct | 8 ms | 12244 KB | Output is correct |
35 | Correct | 8 ms | 12244 KB | Output is correct |
36 | Correct | 35 ms | 15132 KB | Output is correct |
37 | Correct | 55 ms | 16844 KB | Output is correct |
38 | Correct | 81 ms | 18848 KB | Output is correct |
39 | Correct | 73 ms | 19536 KB | Output is correct |
40 | Correct | 61 ms | 17740 KB | Output is correct |
41 | Correct | 46 ms | 15812 KB | Output is correct |
42 | Correct | 44 ms | 15708 KB | Output is correct |
43 | Correct | 641 ms | 16948 KB | Output is correct |
44 | Correct | 7 ms | 11988 KB | Output is correct |
45 | Correct | 6 ms | 12076 KB | Output is correct |
46 | Correct | 6 ms | 11972 KB | Output is correct |
47 | Correct | 6 ms | 11988 KB | Output is correct |
48 | Correct | 6 ms | 11988 KB | Output is correct |
49 | Correct | 17 ms | 12180 KB | Output is correct |
50 | Correct | 18 ms | 12144 KB | Output is correct |
51 | Correct | 30 ms | 12300 KB | Output is correct |
52 | Correct | 24 ms | 12212 KB | Output is correct |
53 | Correct | 520 ms | 15264 KB | Output is correct |
54 | Correct | 957 ms | 19128 KB | Output is correct |
55 | Correct | 907 ms | 19672 KB | Output is correct |
56 | Correct | 846 ms | 17872 KB | Output is correct |
57 | Execution timed out | 3040 ms | 20624 KB | Time limit exceeded |
58 | Halted | 0 ms | 0 KB | - |