Submission #546908

# Submission time Handle Problem Language Result Execution time Memory
546908 2022-04-08T20:28:36 Z ala2 Autobus (COCI22_autobus) C++14
0 / 70
20 ms 22116 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back

using namespace std;
vector<pair<int,int>>v[100100];
const int inf=1e18;
int dp[100][100][1000];
int f(int x,int y,int k)
{
    if(k<0)
      return inf;
    if(x==y)
    {
        return 0;
    }
    if(dp[x][y][k])
        return dp[x][y][k];
    int mn=1e18;
    for(int i=0;i<v[x].size();i++)
    {
        mn=min(mn,v[x][i].second+f(v[x][i].first,y,k-1));
    }
    return dp[x][y][k]=mn;

}
signed main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int c,o,w;
        cin>>c>>o>>w;
        v[c].pb({o,w});
    }
    int q,k;
    cin>>k>>q;
    while(q--)
    {
        int x,y;
        cin>>x>>y;
        cout<<f(x,y,k)<<endl;
    }

}

Compilation message

Main.cpp: In function 'long long int f(long long int, long long int, long long int)':
Main.cpp:20:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i=0;i<v[x].size();i++)
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 22116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2772 KB Output isn't correct
2 Halted 0 ms 0 KB -