답안 #924465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924465 2024-02-09T04:48:18 Z Faisal_Saqib Toll (BOI17_toll) C++17
8 / 100
3000 ms 4548 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});
	}
	for(int lp=0;lp<q;lp++)
	{
		int x,y;
		cin>>x>>y;
		priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
		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});
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3046 ms 3656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3097 ms 3412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 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 6 ms 1628 KB Output is correct
9 Correct 4 ms 1628 KB Output is correct
10 Correct 17 ms 3260 KB Output is correct
11 Correct 108 ms 3160 KB Output is correct
12 Correct 163 ms 4180 KB Output is correct
13 Correct 206 ms 4432 KB Output is correct
14 Correct 146 ms 3668 KB Output is correct
15 Correct 100 ms 2904 KB Output is correct
16 Correct 85 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1628 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 6 ms 1628 KB Output is correct
9 Correct 4 ms 1628 KB Output is correct
10 Correct 17 ms 3260 KB Output is correct
11 Correct 108 ms 3160 KB Output is correct
12 Correct 163 ms 4180 KB Output is correct
13 Correct 206 ms 4432 KB Output is correct
14 Correct 146 ms 3668 KB Output is correct
15 Correct 100 ms 2904 KB Output is correct
16 Correct 85 ms 2904 KB Output is correct
17 Correct 2342 ms 3412 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 1624 KB Output is correct
22 Correct 1 ms 1628 KB Output is correct
23 Correct 11 ms 1628 KB Output is correct
24 Correct 29 ms 1672 KB Output is correct
25 Correct 100 ms 1628 KB Output is correct
26 Correct 73 ms 1628 KB Output is correct
27 Correct 133 ms 3376 KB Output is correct
28 Execution timed out 3040 ms 4548 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3046 ms 3656 KB Time limit exceeded
2 Halted 0 ms 0 KB -