Submission #907440

# Submission time Handle Problem Language Result Execution time Memory
907440 2024-01-15T14:59:42 Z lighton Escape Route (JOI21_escape_route) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define forf(i,a,b) for(int i = a; i<=b; i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
struct Edge{
    int to;
    ll t,c;
};
int N,M;
int S,Q;
vector<Edge> adj[101];
ll inf =1e18;
ll d[101];
ll dijk(int st ,int en , ll t){
    forf(i,0,N) d[i] = inf;
    d[st] = t;
    priority_queue<pair<ll,int> > pq;
    pq.push({-t,st});
    while(pq.size()){
        int now = pq.top().second;
        ll nowt = -pq.top().first;
        pq.pop();
        if(d[now] < nowt) continue;
        for(auto &edge : adj[now]){
            ll newt;
            if(nowt%S + edge.t <= edge.c) newt = nowt+edge.t;
            else newt = S*((nowt/S)+1)+edge.t;
            if(newt < d[edge.to]){
                d[edge.to] = newt;
                pq.push({-newt,edge.to});
            }
        }
    }
    return d[en]-t;
}
int main(){
    scanf("%d %d %d %d" , &N,&M,&S,&Q);
    forf(i,1,M){
        int u,v; ll t,c;
        scanf("%d %d %lld %lld" , &u,&v,&t,&c);
        adj[u].push_back({v,t,c});
        adj[v].push_back({u,t,c});
    }
    while(Q--){
        int u,v; ll t;
        scanf("%d %d %lld" , &u,&v,&t);
        printf("%lld\n" , dijk(u,v,t));
    }

}

Compilation message

escape_route.cpp: In function 'int main()':
escape_route.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d %d %d %d" , &N,&M,&S,&Q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
escape_route.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         scanf("%d %d %lld %lld" , &u,&v,&t,&c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
escape_route.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%d %d %lld" , &u,&v,&t);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccIrFlmG.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccNFBWJE.o:escape_route.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccIrFlmG.o: in function `main':
grader.cpp:(.text.startup+0x6ea): undefined reference to `calculate_necessary_time(int, int, long long, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<long long, std::allocator<long long> >, std::vector<long long, std::allocator<long long> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<long long, std::allocator<long long> >)'
collect2: error: ld returned 1 exit status