Submission #924466

# Submission time Handle Problem Language Result Execution time Memory
924466 2024-02-09T04:49:37 Z Faisal_Saqib Toll (BOI17_toll) C++17
8 / 100
3000 ms 4556 KB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int N=5e4;
vector<pair<int,int>> ma[N];
int dist[N];
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
	int k,n,m,q;
	cin>>k>>n>>m>>q;
	for(int j=0;j<m;j++)
	{
		int a,b,t;
		cin>>a>>b>>t;
		ma[a].push_back({b,t});
	}
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
	for(int lp=0;lp<q;lp++)
	{
		int x,y;
		cin>>x>>y;
		for(int i=0;i<n;i++)
			dist[i]=1e9;
		dist[x]=0;
		int ans=-1;
		pq.push({dist[x],x});
		while(pq.size())
		{
			auto it=pq.top();
			pq.pop();
			if(it.second==y)
			{
				ans=it.first;
				break;
			}
			if(dist[it.second]==it.first)
			{
				for(auto [v,w]:ma[it.second])
				{
					if(dist[v]>(it.first+w) and v<=y)
					{
						dist[v]=it.first+w;
						pq.push({dist[v],v});
					}
				}
			}
		}
		while(pq.size())
			pq.pop();
		cout<<ans<<endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3038 ms 3656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3018 ms 3624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 3 ms 1628 KB Output is correct
8 Correct 7 ms 1628 KB Output is correct
9 Correct 4 ms 1628 KB Output is correct
10 Correct 18 ms 3160 KB Output is correct
11 Correct 105 ms 3164 KB Output is correct
12 Correct 164 ms 4112 KB Output is correct
13 Correct 180 ms 4548 KB Output is correct
14 Correct 144 ms 3676 KB Output is correct
15 Correct 100 ms 2904 KB Output is correct
16 Correct 84 ms 2904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 3 ms 1628 KB Output is correct
8 Correct 7 ms 1628 KB Output is correct
9 Correct 4 ms 1628 KB Output is correct
10 Correct 18 ms 3160 KB Output is correct
11 Correct 105 ms 3164 KB Output is correct
12 Correct 164 ms 4112 KB Output is correct
13 Correct 180 ms 4548 KB Output is correct
14 Correct 144 ms 3676 KB Output is correct
15 Correct 100 ms 2904 KB Output is correct
16 Correct 84 ms 2904 KB Output is correct
17 Correct 2349 ms 3644 KB Output is correct
18 Correct 1 ms 1628 KB Output is correct
19 Correct 1 ms 1628 KB Output is correct
20 Correct 1 ms 1628 KB Output is correct
21 Correct 1 ms 1628 KB Output is correct
22 Correct 1 ms 1492 KB Output is correct
23 Correct 11 ms 1628 KB Output is correct
24 Correct 28 ms 1628 KB Output is correct
25 Correct 101 ms 1628 KB Output is correct
26 Correct 74 ms 1692 KB Output is correct
27 Correct 132 ms 3160 KB Output is correct
28 Execution timed out 3087 ms 4556 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3038 ms 3656 KB Time limit exceeded
2 Halted 0 ms 0 KB -