답안 #546910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546910 2022-04-08T20:29:36 Z ala2 Autobus (COCI22_autobus) C++14
컴파일 오류
0 ms 0 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;
        if(d(x,y,k)<=1e15)
        cout<<f(x,y,k)<<endl;
        else cout<<-1<<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++)
      |                 ~^~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:43:12: error: 'd' was not declared in this scope
   43 |         if(d(x,y,k)<=1e15)
      |            ^