Submission #870752

# Submission time Handle Problem Language Result Execution time Memory
870752 2023-11-09T03:27:36 Z daniel920712 Escape Route (JOI21_escape_route) C++17
0 / 100
9000 ms 154944 KB
#include "escape_route.h"
#include <queue>
#include <utility>
#include <stdio.h>
#define ll long long
using namespace std;
struct aaa
{
    ll a,b,c;
};
priority_queue < pair < ll , ll > , vector < pair < ll , ll > >, greater < pair < ll , ll > > > dij;
vector < long long > Ans;
pair < long long , long long > DP[105][105];
vector < aaa > Next[105];
ll vis[105];
pair < ll, ll > operator +(pair < ll , ll > a, pair < ll , ll > b)
{
    b.first+=a.first;
    if(a.second) b.first++;
    return b;
}
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)
{
    //printf("aaaaa\n");
    ll i,j,k,a,b,c;
    pair < ll , ll > ans;
    aaa tt;
    for(i=0;i<M;i++)
    {
        tt.a=B[i];
        tt.b=L[i];
        tt.c=C[i];
        Next[A[i]].push_back(tt);
        tt.a=A[i];
        Next[B[i]].push_back(tt);
    }
    for(i=0;i<N;i++) for(j=0;j<N;j++) DP[i][j]=make_pair(100,0);
    for(i=0;i<N;i++)
    {
        DP[i][i]=make_pair(0,0);
        vis[i]=-1;
    }
    for(i=0;i<N;i++)
    {
        dij.push(make_pair(i,0));
        while(!dij.empty())
        {
            auto xx=dij.top();
            dij.pop();
            a=xx.first;
            b=xx.second;
            if(vis[b]==i) continue;
            vis[b]=i;
            DP[i][b]=make_pair(0,a);
            for(auto j:Next[b]) if(a+j.b<=j.c) dij.push(make_pair(a+j.b,j.a));
        }

    }
    for(k=0;k<N;k++) for(i=0;i<N;i++) for(j=0;j<N;j++) DP[i][j]=min(DP[i][j],DP[i][k]+DP[k][j]);
    for(i=0;i<N;i++) vis[i]=-1;
    for(i=0;i<Q;i++)
    {
        ans=make_pair(100,0);
        dij.push(make_pair(T[i],U[i]));
        while(!dij.empty())
        {
            auto xx=dij.top();
            dij.pop();
            a=xx.first;
            b=xx.second;
            //printf("%lld %lld %lld\n",a,b,vis[b]);
            if(vis[b]==i) continue;
            vis[b]=i;
            //printf("bb %lld %lld %lld %lld\n",b,a,DP[b][V[i]].first,DP[b][V[i]].second);
            if(b==V[i]) ans=min(ans,make_pair((ll) 0,a));
            ans=min(ans,make_pair(0,a)+DP[b][V[i]]);
            for(auto j:Next[b]) if(a+j.b<=j.c) dij.push(make_pair(a+j.b,j.a));
        }
        //printf("aa %lld %lld %lld\n",ans.first,ans.second,T[i]);
        Ans.push_back(ans.first*S+ans.second-T[i]);
        //`printf("aa %lld\n",Ans[i]);
    }
    return Ans;
}

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:25:18: warning: unused variable 'c' [-Wunused-variable]
   25 |     ll i,j,k,a,b,c;
      |                  ^
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 65360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9013 ms 154944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 65360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 65360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 65360 KB Output isn't correct
2 Halted 0 ms 0 KB -