Submission #806972

# Submission time Handle Problem Language Result Execution time Memory
806972 2023-08-04T11:44:18 Z YassineBenYounes Escape Route (JOI21_escape_route) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include<escape_route.h>
typedef long long ll;
using namespace std;

void init(){
    #ifndef ONLINE_JUDGE
 
freopen("input.txt", "r", stdin);
 
freopen("output.txt", "w", stdout);
 
#endif // ONLINE_JUDGE

}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
const int mx = 100;
const ll inf = 1e18;
vector<vl> graph[mx];

vector<vl> queries[mx];

bool vis[mx];
ll s;
int n, m, q;
ll ans[mx];

void solve(int st, int target, ll t){
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    pq.push({t, st});
    memset(vis, 0, sizeof vis);
    for(int i = 0; i < n;i++){
        ans[i] = inf;
    }
    int k = 0;
    ans[st] = t;
    while(!pq.empty()){
        int node = pq.top().ss;
        ll tm = pq.top().ff;
        pq.pop();
        if(vis[node])continue;
        vis[node] = 1;
        for(vl adj : graph[node]){
            ll nxt = tm + adj[1];
            if(adj[1] > adj[2])continue;
            ll o = nxt % s;
            if((nxt/s) > (tm/s) || o > adj[2]){
                nxt = (tm / s + 1) * s + adj[1];
            }
            ans[adj[0]] = min(ans[adj[0]], nxt);
            pq.push({ans[adj[0]], adj[0]});
        }
    }
    //cout << ans[2] << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n >> m >> s >> q;
    for(int i = 0; i < m;i++){
        ll a, b, l, c;cin >> a >> b >> l >> c;
        graph[a].pb({b, l, c});
        graph[b].pb({a, l, c});
    }
    while(q--){
        ll u, v, t;cin >> u >> v >> t;
        solve(u, v, t);
        cout << ans[v] - t << endl;
    }
}

Compilation message

escape_route.cpp: In function 'void solve(int, int, ll)':
escape_route.cpp:41:9: warning: unused variable 'k' [-Wunused-variable]
   41 |     int k = 0;
      |         ^
escape_route.cpp: In function 'void init()':
escape_route.cpp:9:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
escape_route.cpp:11:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cchL5FLg.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccgEUlwd.o:escape_route.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cchL5FLg.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