Submission #924467

# Submission time Handle Problem Language Result Execution time Memory
924467 2024-02-09T04:50:10 Z Faisal_Saqib Toll (BOI17_toll) C++17
8 / 100
3000 ms 4540 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<<'\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3069 ms 3388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3041 ms 3620 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 2 ms 1628 KB Output is correct
8 Correct 5 ms 1628 KB Output is correct
9 Correct 4 ms 1624 KB Output is correct
10 Correct 16 ms 3164 KB Output is correct
11 Correct 109 ms 3364 KB Output is correct
12 Correct 155 ms 4176 KB Output is correct
13 Correct 207 ms 4540 KB Output is correct
14 Correct 151 ms 3676 KB Output is correct
15 Correct 99 ms 2908 KB Output is correct
16 Correct 86 ms 2920 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 2 ms 1628 KB Output is correct
8 Correct 5 ms 1628 KB Output is correct
9 Correct 4 ms 1624 KB Output is correct
10 Correct 16 ms 3164 KB Output is correct
11 Correct 109 ms 3364 KB Output is correct
12 Correct 155 ms 4176 KB Output is correct
13 Correct 207 ms 4540 KB Output is correct
14 Correct 151 ms 3676 KB Output is correct
15 Correct 99 ms 2908 KB Output is correct
16 Correct 86 ms 2920 KB Output is correct
17 Correct 2347 ms 3508 KB Output is correct
18 Correct 1 ms 1880 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 1628 KB Output is correct
23 Correct 7 ms 1628 KB Output is correct
24 Correct 25 ms 1664 KB Output is correct
25 Correct 99 ms 1720 KB Output is correct
26 Correct 70 ms 1696 KB Output is correct
27 Correct 131 ms 3384 KB Output is correct
28 Execution timed out 3052 ms 4296 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3069 ms 3388 KB Time limit exceeded
2 Halted 0 ms 0 KB -