답안 #463693

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

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

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

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>>());
	
	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<q; ++i){
		int a, b; cin>>a>>b;
		
		cout<<dijkstra(a, b, n)<<'\n';
	}
	
	//cout<<'\n';
}

Compilation message

toll.cpp: In function 'int64_t dijkstra(int64_t, int64_t, 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 Execution timed out 3030 ms 4364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3083 ms 6104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 6 ms 404 KB Output is correct
8 Correct 30 ms 460 KB Output is correct
9 Correct 23 ms 332 KB Output is correct
10 Correct 26 ms 4172 KB Output is correct
11 Correct 419 ms 5876 KB Output is correct
12 Correct 797 ms 7920 KB Output is correct
13 Correct 944 ms 8644 KB Output is correct
14 Correct 618 ms 6816 KB Output is correct
15 Correct 485 ms 4420 KB Output is correct
16 Correct 393 ms 4428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 6 ms 404 KB Output is correct
8 Correct 30 ms 460 KB Output is correct
9 Correct 23 ms 332 KB Output is correct
10 Correct 26 ms 4172 KB Output is correct
11 Correct 419 ms 5876 KB Output is correct
12 Correct 797 ms 7920 KB Output is correct
13 Correct 944 ms 8644 KB Output is correct
14 Correct 618 ms 6816 KB Output is correct
15 Correct 485 ms 4420 KB Output is correct
16 Correct 393 ms 4428 KB Output is correct
17 Execution timed out 3066 ms 5964 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3030 ms 4364 KB Time limit exceeded
2 Halted 0 ms 0 KB -