Submission #491564

# Submission time Handle Problem Language Result Execution time Memory
491564 2021-12-03T09:26:34 Z stefantaga Toll (BOI17_toll) C++14
0 / 100
3000 ms 6632 KB
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;
int k,n,m,o,a,b,din[50005],minim;
vector <pair <int,int>> v[50005];
void dfs(int x,int query,int cost)
{
    if (x/k>query/k)
    {
        return;
    }
    if (x==query)
    {
        minim=min(minim,query);
    }
    for (int i=0;i<v[x].size();i++)
    {
        dfs(v[x][i].first,query,v[x][i].second+cost);
    }
}
int i;
int main()
{
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>k>>n>>m>>o;
    for (i=1;i<=m;i++)
    {
        int x,y,cost;
        cin>>x>>y>>cost;
        v[x].push_back({y,cost});
    }
    for (i=1;i<=o;i++)
    {
        cin>>a>>b;
        minim = INF;
        dfs(a,b,0);
        if (minim==INF)
        {
            cout<<"-1"<<'\n';
        }
        else
        cout<<minim<<'\n';
    }
    return 0;
}

Compilation message

toll.cpp: In function 'void dfs(int, int, int)':
toll.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i=0;i<v[x].size();i++)
      |                  ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 3061 ms 6632 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3055 ms 4676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3061 ms 6632 KB Time limit exceeded
2 Halted 0 ms 0 KB -