Submission #907443

# Submission time Handle Problem Language Result Execution time Memory
907443 2024-01-15T15:07:00 Z lighton Escape Route (JOI21_escape_route) C++17
5 / 100
9000 ms 155104 KB
#include "escape_route.h"
#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; ll s;
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;
}
std::vector<long long> calculate_necessary_time(
    int N, int M, long long S, int Q, std::vector<int> A, std::vector<int> B,
    std::vector<long long> L, std::vector<long long> C, std::vector<int> U,
    std::vector<int> V, std::vector<long long> T) {
    n=N;s=S;
    vector<ll> ans(Q);
    forf(i,0,M-1){
        adj[A[i]].push_back({B[i],L[i],C[i]});
        adj[B[i]].push_back({A[i],L[i],C[i]});
    }
    forf(i,0,Q-1){
        ans[i]= dijk(U[i],V[i],T[i]);
    }
     return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 65116 KB Output is correct
2 Correct 20 ms 65116 KB Output is correct
3 Correct 29 ms 65116 KB Output is correct
4 Correct 13 ms 65116 KB Output is correct
5 Correct 19 ms 65116 KB Output is correct
6 Correct 14 ms 65116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 9094 ms 155104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 65116 KB Output is correct
2 Correct 20 ms 65116 KB Output is correct
3 Correct 29 ms 65116 KB Output is correct
4 Correct 13 ms 65116 KB Output is correct
5 Correct 19 ms 65116 KB Output is correct
6 Correct 14 ms 65116 KB Output is correct
7 Execution timed out 9094 ms 155104 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 65116 KB Output is correct
2 Correct 20 ms 65116 KB Output is correct
3 Correct 29 ms 65116 KB Output is correct
4 Correct 13 ms 65116 KB Output is correct
5 Correct 19 ms 65116 KB Output is correct
6 Correct 14 ms 65116 KB Output is correct
7 Execution timed out 9094 ms 155104 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 65116 KB Output is correct
2 Correct 20 ms 65116 KB Output is correct
3 Correct 29 ms 65116 KB Output is correct
4 Correct 13 ms 65116 KB Output is correct
5 Correct 19 ms 65116 KB Output is correct
6 Correct 14 ms 65116 KB Output is correct
7 Execution timed out 9094 ms 155104 KB Time limit exceeded
8 Halted 0 ms 0 KB -