Submission #876045

# Submission time Handle Problem Language Result Execution time Memory
876045 2023-11-21T07:11:39 Z Regulus Escape Route (JOI21_escape_route) C++17
0 / 100
9000 ms 118452 KB
#include "escape_route.h"
#include <bits/stdc++.h>            // pA

#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using ppl = pair<pll, ll>;
 
const int N = 2e5+5;
const int INF = 2e9;
pll dis[N];
vector<ll> ans;
vector<pll> g[N];
priority_queue<ppl, vector<ppl>, greater<ppl> > pq;
 
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)
{
    int i, j, n=N, m=M;
 
    for (i=0; i < m; ++i) g[A[i]].pb(B[i], i), g[B[i]].pb(A[i], i);
    
    for (int t=0; t < Q; ++t)
    {
        while (!pq.empty()) pq.pop();
        for (i=0; i < n; ++i) dis[i] = {INF, INF};
        dis[U[t]] = {0, T[t]}, pq.push({pll{0, 0}, U[t]});
        while (!pq.empty())
        {
            int x = pq.top().S;
            pq.pop();
            for (auto p : g[x])
            {
                ll v = p.F, id = p.S;
                pll tmp = dis[x];
                tmp.S += L[id];
                if (tmp.S > C[id]) ++tmp.F, tmp.S = 0;
                if (tmp < dis[v])
                {
                    dis[v] = tmp, pq.push({dis[v], v});
                }
            }
        }
        ans.pb(dis[V[t]].F*s + dis[V[t]].S);
    }
 
    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:26:12: warning: unused variable 'j' [-Wunused-variable]
   26 |     int i, j, n=N, m=M;
      |            ^
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 71516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9062 ms 118452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 71516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 71516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 71516 KB Output isn't correct
2 Halted 0 ms 0 KB -