제출 #864536

#제출 시각아이디문제언어결과실행 시간메모리
864536maks007Toll (BOI17_toll)C++14
56 / 100
3016 ms6400 KiB
// Bismi ALlah
#include "bits/stdc++.h"
 
using namespace std;
 
signed main () {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m, k, query;
	cin >> k >> n >> m >> query;
	vector<pair <int,int>> g[n];
	for(int i = 0; i < m; i ++) {
		int u, v;
		cin >> u >> v;
		int w;
		cin >> w;
		g[v].push_back({u, w});
	}
	int dp[n];
	while(query --) {
		int a, b;
		cin >> a >> b;
		
		for(int i = 0; i < n; i ++) dp[i] = 1e9;
		dp[b] = 0;
		for(int i = n - 1; i >= 0; i--) {
			if(dp[i] != 1e9) {
				for(auto [u, w] : g[i]) {
					dp[u] = min(dp[u], dp[i] + w);
				}
			}
		}
		if(dp[a] == 1e9) cout << -1 << "\n";
		else cout << dp[a] << "\n";
		
	}
	return 0;
}

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

toll.cpp: In function 'int main()':
toll.cpp:28:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |     for(auto [u, w] : g[i]) {
      |              ^
#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...