답안 #923911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923911 2024-02-08T06:12:11 Z Darren0724 Escape Route (JOI21_escape_route) C++17
5 / 100
9000 ms 111892 KB
#include "escape_route.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const long long INF=1e18;
vector<long long> calculate_necessary_time(int n, int m, long long s, int q, vector<int> a, vector<int> b,vector<long long> l, vector<long long> c, vector<int> u,vector<int> v, vector<long long> t) {
    vector<int> adj[n+1];
    for(int i=0;i<m;i++){
        adj[a[i]].push_back(i);
        adj[b[i]].push_back(i);
    }
    vector<vector<long long>> dis(n,vector<long long>(n,INF)),dis1(n,vector<long long>(n,-1));
    for(int i=0;i<n;i++){
        dis1[i][i]=s;
        priority_queue<pair<int,int>> pq;
        pq.push({s,i});
        while(pq.size()){
            auto [d,k]=pq.top();
            pq.pop();
            if(dis1[i][k]!=d)continue;
            for(int j:adj[k]){
                int to=(a[j]==k?b[j]:a[j]);
                int cost=min(c[j]-l[j],dis1[i][k]-l[j]);
                if(dis1[i][to]<cost){
                    dis1[i][to]=cost;
                    pq.push({cost,to});
                }
            }
        }
    }   
    for(int i=0;i<n;i++){
        dis[i][i]=0;
        priority_queue<pair<int,int>> pq;
        pq.push({0,i});
        while(pq.size()){
            auto [d,k]=pq.top();
            pq.pop();
            d=-d;
            if(dis[i][k]!=d)continue;
            for(int j:adj[k]){
                int to=(a[j]==k?b[j]:a[j]);
                int d1=(d%s<=c[j]-l[j]?d:(d/s+1)*s);
                int cost=d1+l[j];
                if(dis[i][to]>cost){
                    dis[i][to]=cost;
                    pq.push({-cost,to});
                }
            }
        }
    }
    vector<long long> ans1(q);
    for(int i=0;i<q;i++){
        long long a1=u[i],b1=v[i],t1=t[i];
        long long ans=INF;
        fill(dis[a1].begin(),dis[a1].end(),INF);
        dis[a1][a1]=t1;
        priority_queue<pair<long long,int>> pq;
        pq.push({-t1,a1});
        while(pq.size()){
            auto [d,k]=pq.top();
            pq.pop();
            d=-d;
            if(dis[a1][k]!=d)continue;
            for(int j:adj[k]){
                int to=(a[j]==k?b[j]:a[j]);
                long long d1=(d%s<=c[j]-l[j]?d:(d/s+1)*s);
                long long cost=d1+l[j];
                if(dis[a1][to]>cost){
                    dis[a1][to]=cost;
                    pq.push({-cost,to});
                }
            }
        }
        ans1[i]=dis[a1][b1]-t1;
    }
    return ans1;
}

Compilation message

escape_route.cpp: In function 'std::vector<long long int> calculate_necessary_time(int, int, long long int, int, std::vector<int>, std::vector<int>, std::vector<long long int>, std::vector<long long int>, std::vector<int>, std::vector<int>, std::vector<long long int>)':
escape_route.cpp:54:19: warning: unused variable 'ans' [-Wunused-variable]
   54 |         long long ans=INF;
      |                   ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 65112 KB Output is correct
2 Correct 18 ms 65116 KB Output is correct
3 Correct 30 ms 65060 KB Output is correct
4 Correct 9 ms 65116 KB Output is correct
5 Correct 19 ms 65192 KB Output is correct
6 Correct 10 ms 65112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 9093 ms 111892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 65112 KB Output is correct
2 Correct 18 ms 65116 KB Output is correct
3 Correct 30 ms 65060 KB Output is correct
4 Correct 9 ms 65116 KB Output is correct
5 Correct 19 ms 65192 KB Output is correct
6 Correct 10 ms 65112 KB Output is correct
7 Execution timed out 9093 ms 111892 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 65112 KB Output is correct
2 Correct 18 ms 65116 KB Output is correct
3 Correct 30 ms 65060 KB Output is correct
4 Correct 9 ms 65116 KB Output is correct
5 Correct 19 ms 65192 KB Output is correct
6 Correct 10 ms 65112 KB Output is correct
7 Execution timed out 9093 ms 111892 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 65112 KB Output is correct
2 Correct 18 ms 65116 KB Output is correct
3 Correct 30 ms 65060 KB Output is correct
4 Correct 9 ms 65116 KB Output is correct
5 Correct 19 ms 65192 KB Output is correct
6 Correct 10 ms 65112 KB Output is correct
7 Execution timed out 9093 ms 111892 KB Time limit exceeded
8 Halted 0 ms 0 KB -