제출 #1128792

#제출 시각아이디문제언어결과실행 시간메모리
1128792MuhammetToll (BOI17_toll)C++20
46 / 100
3094 ms4768 KiB
#include <bits/stdc++.h> using namespace std; #define SZ(s) (int)s.size() #define ff first #define ss second int k, n, m, o; vector <vector <pair<int,int>>> v; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> k >> n >> m >> o; v.resize(n+1); vector <int> p(n+1,0); for(int i = 1; i <= m; i++){ int u1, u2, s; cin >> u1 >> u2 >> s; v[u1].push_back({u2,s}); } while(o--){ int a, b; cin >> a >> b; vector <int> dis(n+1, 1e9); dis[a] = 0; for(int i = a; i < n; i++){ for(auto j : v[i]){ dis[j.ff] = min(dis[j.ff], dis[i] + j.ss); } } cout << (dis[b] == 1e9 ? -1 : dis[b]) << '\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...