답안 #921984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921984 2024-02-04T15:53:41 Z browntoad Escape Route (JOI21_escape_route) C++17
0 / 100
9000 ms 155012 KB
#include <bits/stdc++.h>
#include "escape_route.h"
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
// #define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define RREP1(i,n) for (int i=(n); i>=1; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<ll, ll>
#define pip pair<int, pii>
#define ppi pair<pii, ll>
#define pdd pair<double ,double>
#define pcc pair<char, char>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#endif
 
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 998244353;
const ll maxn=505;
const ll maxm=15;
const double PI=acos(-1);
 
ll pw(ll x, ll p, ll m=mod){
    if (p < 0) return 0;
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=m;
        }
        x*=x;
        x%=m;
        p>>=1;
    }
    return ret;
}
 
ll inv(ll a, ll m=mod){
    return pw(a,m-2,m);
}
int n, m, SS, q;
struct edge{
    int v;
    ll l, c; // length, check
};
vector<edge> g[maxn];
 
pii D(ppi U, edge E){
    if (U.f.s + E.l > E.c){
        U.f.f += SS-U.f.s;
        U.f.s = 0;
 
        U.f.f += E.l;
        U.f.s = E.l;
    }
    else {
        U.f.f += E.l;
        U.f.s += E.l;
    }
    return U.f;
}
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; m = M; SS = S; q = Q;
    REP(i, m){
        int u, v; ll a, b; 
      	u = A[i]; v = B[i]; a = L[i]; b = C[i];
      
        g[u].pb({v, a, b});
        g[v].pb({u, a, b});
    }
  	vector<ll> ret;
    for (int z = 0; z < Q; z++){
        int a, b; ll t; a = U[z]; b = V[z]; t = T[z];
        priority_queue<ppi, vector<ppi>, greater<ppi> > pq;
        pq.push({{0ll, t}, a}); // mod and node
 
        vector<bool> occ(n+1);
        vector<pii> dis(n+1);
        pii ou = {inf, inf};
        fill(ALL(dis), ou);
        dis[a] = {0ll, t};
        pii tmp;
        while(SZ(pq)){
            ppi tp = pq.top(); pq.pop();
            if (occ[tp.s]) continue;
            occ[tp.s] = 1;
            for (auto y:g[tp.s]){
                if (!occ[y.v]){
                    tmp = D(tp, y);
                    if (tmp < dis[y.v]){
                        dis[y.v] = tmp;
                        pq.push({dis[y.v], y.v});
                    }
                }
            }
        }
      	ret.pb(dis[b].f);
    }
  	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 65116 KB Output is correct
2 Correct 17 ms 65116 KB Output is correct
3 Incorrect 28 ms 65112 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 9071 ms 155012 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 65116 KB Output is correct
2 Correct 17 ms 65116 KB Output is correct
3 Incorrect 28 ms 65112 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 65116 KB Output is correct
2 Correct 17 ms 65116 KB Output is correct
3 Incorrect 28 ms 65112 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 65116 KB Output is correct
2 Correct 17 ms 65116 KB Output is correct
3 Incorrect 28 ms 65112 KB Output isn't correct
4 Halted 0 ms 0 KB -