Submission #924488

# Submission time Handle Problem Language Result Execution time Memory
924488 2024-02-09T05:35:30 Z Muhammad_Aneeq Toll (BOI17_toll) C++17
0 / 100
3000 ms 5740 KB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/

#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
map<pair<int,int>,int>d;
int const N=5e4+10;
vector<pair<int,int>>nei[N]={};
int dist[N]={};
bool vis[N]={};
int ans=0;
void dfs(int n,int v,int cost=0)
{
    if (n>v)
        return ;
    if (n==v)
    {
        ans=min(ans,cost);
        return;
    }
    if (cost>ans)
        return;
    for (auto [j,w]:nei[n])
        dfs(j,v,cost+w);
}
inline void solve()
{
    int n,m,k,o;
    cin>>k>>n>>m>>o;
    while (m--)
    {
        int a,b,t;
        cin>>a>>b>>t;
        nei[a].push_back({b,t});
    }
    vector<pair<int,int>>ord;
    while (o--)
    {
        int x,y;
        cin>>x>>y;
        ans=1e9+10;
        dfs(x,y);
        cout<<(ans==1e9+10?-1:ans)<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        solve();
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3051 ms 5740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3025 ms 3160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1636 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 Execution timed out 3080 ms 1628 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1636 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 Execution timed out 3080 ms 1628 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3051 ms 5740 KB Time limit exceeded
2 Halted 0 ms 0 KB -