Submission #806970

#TimeUsernameProblemLanguageResultExecution timeMemory
806970YassineBenYounesEscape Route (JOI21_escape_route)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.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 (stderr)

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