Submission #463695

# Submission time Handle Problem Language Result Execution time Memory
463695 2021-08-11T13:53:25 Z _Avocado_ Toll (BOI17_toll) C++14
18 / 100
3000 ms 8372 KB
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

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

vector<int>dijkstra(int s, 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;
}

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});
	}
	
	vector<int>zero = dijkstra(0, n);
	
	for(int i = 0; i<q; ++i){
		int a, b; cin>>a>>b;
		if(a != 0){
			vector<int>cur = dijkstra(a, n);
			cout<<cur[b]<<'\n';
		}
		else cout<<zero[b]<<'\n';
	}
	
	//cout<<'\n';
}

Compilation message

toll.cpp: In function 'std::vector<long int> dijkstra(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]){
      |            ^
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 3844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4412 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 244 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 204 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
8 Correct 4 ms 460 KB Output is correct
9 Correct 24 ms 4328 KB Output is correct
10 Correct 71 ms 8132 KB Output is correct
11 Correct 60 ms 6244 KB Output is correct
12 Correct 40 ms 5108 KB Output is correct
13 Correct 87 ms 8372 KB Output is correct
14 Correct 49 ms 5380 KB Output is correct
15 Correct 46 ms 4468 KB Output is correct
16 Correct 40 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 6 ms 332 KB Output is correct
8 Correct 28 ms 460 KB Output is correct
9 Correct 20 ms 332 KB Output is correct
10 Correct 27 ms 3788 KB Output is correct
11 Correct 430 ms 4676 KB Output is correct
12 Correct 727 ms 6200 KB Output is correct
13 Correct 858 ms 6640 KB Output is correct
14 Correct 606 ms 5444 KB Output is correct
15 Correct 417 ms 3496 KB Output is correct
16 Correct 387 ms 3416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 6 ms 332 KB Output is correct
8 Correct 28 ms 460 KB Output is correct
9 Correct 20 ms 332 KB Output is correct
10 Correct 27 ms 3788 KB Output is correct
11 Correct 430 ms 4676 KB Output is correct
12 Correct 727 ms 6200 KB Output is correct
13 Correct 858 ms 6640 KB Output is correct
14 Correct 606 ms 5444 KB Output is correct
15 Correct 417 ms 3496 KB Output is correct
16 Correct 387 ms 3416 KB Output is correct
17 Execution timed out 3067 ms 4788 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 3844 KB Time limit exceeded
2 Halted 0 ms 0 KB -