답안 #463689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
463689 2021-08-11T13:41:48 Z _Avocado_ Toll (BOI17_toll) C++14
0 / 100
222 ms 524292 KB
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

vector<vector<pair<int, int>>>graph;
vector<vector<int>>dist;

void dijkstra(int s){
	priority_queue<pair<int, int>>pq;
	pq.push({0, s});
	
	while(!pq.empty()){
		int d = -pq.top().first;
		int u = pq.top().second;
		pq.pop();
		
		if(dist[s][u] != -1) continue;
		
		dist[s][u] = d;
		
		for(auto [v, w]: graph[u]){
			pq.push({-(w+dist[s][u]), v});
		}
	}
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int k, n, m, q; cin>>k>>n>>m>>q;
	
	graph.assign(n, vector<pair<int, int>>());
	dist.assign(n, vector<int>(n, -1));
	
	for(int i = 0; i<m; ++i){
		int a, b, c; cin>>a>>b>>c;
		graph[a].push_back({b, c});
	}
	
	for(int i = 0; i<n; ++i){
		dijkstra(i);
	}
	
	for(int i = 0; i<q; ++i){
		int a, b; cin>>a>>b;
		
		cout<<dist[a][b]<<'\n';
	}
	
	//cout<<'\n';
}

Compilation message

toll.cpp: In function 'void dijkstra(int64_t)':
toll.cpp:21:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   21 |   for(auto [v, w]: graph[u]){
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 215 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 222 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 6 ms 8140 KB Output is correct
7 Correct 45 ms 8260 KB Output is correct
8 Correct 207 ms 8396 KB Output is correct
9 Correct 139 ms 8332 KB Output is correct
10 Runtime error 222 ms 524292 KB Execution killed with signal 9
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 6 ms 8140 KB Output is correct
7 Correct 45 ms 8260 KB Output is correct
8 Correct 207 ms 8396 KB Output is correct
9 Correct 139 ms 8332 KB Output is correct
10 Runtime error 222 ms 524292 KB Execution killed with signal 9
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 215 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -