# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
924464 |
2024-02-09T04:47:12 Z |
Faisal_Saqib |
Toll (BOI17_toll) |
C++17 |
|
3000 ms |
11160 KB |
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int N=5e4;
vector<pair<int,int>> ma[N],query[N];
vector<int> MinDist[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;
// q<=1e4
for(int j=0;j<m;j++)
{
int a,b,t;
cin>>a>>b>>t;
ma[a].push_back({b,t});
}
// for(int i=n-1;i>=0;i--)
// {
// MinDist[i].push_back(0);
// for(int j=i+1;j<n;j++)
// MinDist[i].push_back(1e9);
// }
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=1;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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3028 ms |
6008 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3026 ms |
5732 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3932 KB |
Output is correct |
2 |
Correct |
1 ms |
3932 KB |
Output is correct |
3 |
Correct |
2 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
3932 KB |
Output is correct |
5 |
Correct |
1 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
3 ms |
3932 KB |
Output is correct |
8 |
Correct |
6 ms |
3932 KB |
Output is correct |
9 |
Correct |
5 ms |
3928 KB |
Output is correct |
10 |
Runtime error |
21 ms |
11160 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3932 KB |
Output is correct |
2 |
Correct |
1 ms |
3932 KB |
Output is correct |
3 |
Correct |
2 ms |
3932 KB |
Output is correct |
4 |
Correct |
1 ms |
3932 KB |
Output is correct |
5 |
Correct |
1 ms |
3932 KB |
Output is correct |
6 |
Correct |
2 ms |
3932 KB |
Output is correct |
7 |
Correct |
3 ms |
3932 KB |
Output is correct |
8 |
Correct |
6 ms |
3932 KB |
Output is correct |
9 |
Correct |
5 ms |
3928 KB |
Output is correct |
10 |
Runtime error |
21 ms |
11160 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3028 ms |
6008 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |