제출 #1306198

#제출 시각아이디문제언어결과실행 시간메모리
1306198Robert_juniorToll (BOI17_toll)C++20
100 / 100
2075 ms6424 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ll long long #define all(x) x.begin(), x.end() #define ins insert #define pb push_back #define F first #define S second #define bt bitset<5010> const int N = 1e5 + 100, K = 1610; const int mod = 998244353; int n, m, k, q; vector<pair<int, int>>g[N]; int dp[N]; void solve(){ cin>>k>>n>>m>>q; for(int i = 1; i <= m; i++){ int u, v, w; cin>>u>>v>>w; g[u].pb({v, w}); } while(q--){ int a, b; cin>>a>>b; for(int i = a; i <= b; i++){ dp[i] = INT_MAX; } dp[a] = 0; for(int i = a; i <= b; i++){ for(auto [to, w] : g[i]){ dp[to] = min(dp[to], dp[i] + w); } } cout<<(dp[b] == INT_MAX ? -1 : dp[b])<<'\n'; } } main(){ ios_base :: sync_with_stdio(false); cin.tie(nullptr); int t = 1; //cin>>t; while(t--){ solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

toll.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main(){
      | ^~~~
#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...