Submission #557548

#TimeUsernameProblemLanguageResultExecution timeMemory
557548fatemetmhrToll (BOI17_toll)C++17
46 / 100
3076 ms10412 KiB
// `Be name khoda` // #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn5 = 2e5 + 10; const int inf = 1e9; int dis[maxn5]; vector <pair<int, int>> jda[maxn5]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int k, n, m, q; cin >> k >> n >> m >> q; for(int i = 0; i < m; i++){ int a, b, t; cin >> a >> b >> t; jda[b].pb({a, t}); } for(int i = 0; i < q; i++){ int a, b; cin >> a >> b; fill(dis, dis + n + 4, inf); dis[b] = 0; for(int i = b; i > a; i--){ for(auto [u, t] : jda[i]) dis[u] = min(dis[u], dis[i] + t); } if(dis[a] == inf) dis[a] = -1; cout << dis[a] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...