답안 #729053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729053 2023-04-23T12:58:13 Z grogu Shortcut (IOI16_shortcut) C++14
0 / 100
2000 ms 47284 KB
#include "shortcut.h"
#include <bits/stdc++.h>
#define endl '\n'
#define here cerr<<"=========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define ll long long
#define pb push_back
#define popb pop_back
#define all(a_) a_.begin(),a_.end()
#define pll pair<ll,ll>
#define sc second
#define fi first
#define llinf 1000000000000000LL
#define ceri(a,l,r) {for(ll i = l;i<=r;i++) cerr<<a[i]<< " ";cerr<<endl;}

using namespace std;
#define maxn 2000005
ll n,c,tsz;
vector<pll> g[maxn];
ll dis[maxn];
ll naj(ll x){
    for(ll i = 0;i<=tsz;i++) dis[i] = llinf;
    dis[x] = 0;
    priority_queue<pll> pq;
    pq.push({0,x});
    while(pq.size()){
        ll u = pq.top().sc;
        ll cur = -pq.top().fi;
        pq.pop();
        if(cur!=dis[u]) continue;
        for(pll p : g[u]){
            ll s = p.fi;
            ll w = p.sc;
            if(cur+w<dis[s]){
                dis[s] = cur+w;
                pq.push({-dis[s],s});
            }
        }
    }
    ll ans = 1;
    for(ll i = 1;i<=tsz;i++) if(dis[i]>dis[ans]) ans = i;
    return ans;
}
ll find_shortcut(int N, vector<int> L, vector<int> D, int C)
{
    n = N;
    tsz = n;
    c = C;
    for(ll i = 1;i<n;i++){
        g[i].pb({i+1,L[i-1]});
        g[i+1].pb({i,L[i-1]});
    }
    for(ll i = 1;i<=n;i++) if(D[i-1]){
        g[i].pb({++tsz,D[i-1]});
        g[tsz].pb({i,D[i-1]});
    }
    ll ans = llinf;
    for(ll i = 1;i<=n;i++){
        for(ll j = i+1;j<=n;j++){
            g[i].pb({j,c});
            g[j].pb({i,c});
            ll cur = 0;
            for(ll k = 1;k<=tsz;k++){
                ll f = naj(k);
                cur = max(cur,dis[f]);
            }
            ans = min(ans,cur);
            g[i].popb();
            g[j].popb();
        }
    }
    return ans;
}
/**
4 10
10 20 20
0 40 0 30

9 30
10 10 10 10 10 10 10 10
20 0 30 0 0 40 0 40 0
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47188 KB n = 4, 80 is a correct answer
2 Correct 25 ms 47248 KB n = 9, 110 is a correct answer
3 Correct 24 ms 47188 KB n = 4, 21 is a correct answer
4 Correct 25 ms 47188 KB n = 3, 4 is a correct answer
5 Correct 29 ms 47144 KB n = 2, 62 is a correct answer
6 Correct 23 ms 47188 KB n = 2, 3 is a correct answer
7 Correct 24 ms 47164 KB n = 3, 29 is a correct answer
8 Correct 25 ms 47216 KB n = 2, 3 is a correct answer
9 Correct 27 ms 47176 KB n = 2, 3 is a correct answer
10 Correct 24 ms 47260 KB n = 2, 2000000001 is a correct answer
11 Correct 26 ms 47188 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 47252 KB n = 3, 3000000000 is a correct answer
13 Correct 26 ms 47188 KB n = 3, 3000000000 is a correct answer
14 Correct 25 ms 47188 KB n = 4, 3000000001 is a correct answer
15 Correct 24 ms 47264 KB n = 4, 4000000000 is a correct answer
16 Correct 23 ms 47164 KB n = 5, 4000000000 is a correct answer
17 Correct 24 ms 47276 KB n = 10, 1000000343 is a correct answer
18 Correct 26 ms 47188 KB n = 10, 3189 is a correct answer
19 Correct 23 ms 47272 KB n = 10, 7000000000 is a correct answer
20 Correct 23 ms 47276 KB n = 5, 12 is a correct answer
21 Correct 23 ms 47188 KB n = 5, 25 is a correct answer
22 Correct 25 ms 47244 KB n = 2, 122 is a correct answer
23 Correct 25 ms 47188 KB n = 10, 117 is a correct answer
24 Correct 24 ms 47284 KB n = 10, 336 is a correct answer
25 Correct 24 ms 47180 KB n = 10, 438 is a correct answer
26 Correct 24 ms 47176 KB n = 10, 206 is a correct answer
27 Correct 27 ms 47220 KB n = 10, 636 is a correct answer
28 Correct 25 ms 47188 KB n = 4, 2399 is a correct answer
29 Correct 28 ms 47260 KB n = 10, 10992 is a correct answer
30 Correct 25 ms 47196 KB n = 10, 3112 is a correct answer
31 Execution timed out 2082 ms 47176 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47188 KB n = 4, 80 is a correct answer
2 Correct 25 ms 47248 KB n = 9, 110 is a correct answer
3 Correct 24 ms 47188 KB n = 4, 21 is a correct answer
4 Correct 25 ms 47188 KB n = 3, 4 is a correct answer
5 Correct 29 ms 47144 KB n = 2, 62 is a correct answer
6 Correct 23 ms 47188 KB n = 2, 3 is a correct answer
7 Correct 24 ms 47164 KB n = 3, 29 is a correct answer
8 Correct 25 ms 47216 KB n = 2, 3 is a correct answer
9 Correct 27 ms 47176 KB n = 2, 3 is a correct answer
10 Correct 24 ms 47260 KB n = 2, 2000000001 is a correct answer
11 Correct 26 ms 47188 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 47252 KB n = 3, 3000000000 is a correct answer
13 Correct 26 ms 47188 KB n = 3, 3000000000 is a correct answer
14 Correct 25 ms 47188 KB n = 4, 3000000001 is a correct answer
15 Correct 24 ms 47264 KB n = 4, 4000000000 is a correct answer
16 Correct 23 ms 47164 KB n = 5, 4000000000 is a correct answer
17 Correct 24 ms 47276 KB n = 10, 1000000343 is a correct answer
18 Correct 26 ms 47188 KB n = 10, 3189 is a correct answer
19 Correct 23 ms 47272 KB n = 10, 7000000000 is a correct answer
20 Correct 23 ms 47276 KB n = 5, 12 is a correct answer
21 Correct 23 ms 47188 KB n = 5, 25 is a correct answer
22 Correct 25 ms 47244 KB n = 2, 122 is a correct answer
23 Correct 25 ms 47188 KB n = 10, 117 is a correct answer
24 Correct 24 ms 47284 KB n = 10, 336 is a correct answer
25 Correct 24 ms 47180 KB n = 10, 438 is a correct answer
26 Correct 24 ms 47176 KB n = 10, 206 is a correct answer
27 Correct 27 ms 47220 KB n = 10, 636 is a correct answer
28 Correct 25 ms 47188 KB n = 4, 2399 is a correct answer
29 Correct 28 ms 47260 KB n = 10, 10992 is a correct answer
30 Correct 25 ms 47196 KB n = 10, 3112 is a correct answer
31 Execution timed out 2082 ms 47176 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47188 KB n = 4, 80 is a correct answer
2 Correct 25 ms 47248 KB n = 9, 110 is a correct answer
3 Correct 24 ms 47188 KB n = 4, 21 is a correct answer
4 Correct 25 ms 47188 KB n = 3, 4 is a correct answer
5 Correct 29 ms 47144 KB n = 2, 62 is a correct answer
6 Correct 23 ms 47188 KB n = 2, 3 is a correct answer
7 Correct 24 ms 47164 KB n = 3, 29 is a correct answer
8 Correct 25 ms 47216 KB n = 2, 3 is a correct answer
9 Correct 27 ms 47176 KB n = 2, 3 is a correct answer
10 Correct 24 ms 47260 KB n = 2, 2000000001 is a correct answer
11 Correct 26 ms 47188 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 47252 KB n = 3, 3000000000 is a correct answer
13 Correct 26 ms 47188 KB n = 3, 3000000000 is a correct answer
14 Correct 25 ms 47188 KB n = 4, 3000000001 is a correct answer
15 Correct 24 ms 47264 KB n = 4, 4000000000 is a correct answer
16 Correct 23 ms 47164 KB n = 5, 4000000000 is a correct answer
17 Correct 24 ms 47276 KB n = 10, 1000000343 is a correct answer
18 Correct 26 ms 47188 KB n = 10, 3189 is a correct answer
19 Correct 23 ms 47272 KB n = 10, 7000000000 is a correct answer
20 Correct 23 ms 47276 KB n = 5, 12 is a correct answer
21 Correct 23 ms 47188 KB n = 5, 25 is a correct answer
22 Correct 25 ms 47244 KB n = 2, 122 is a correct answer
23 Correct 25 ms 47188 KB n = 10, 117 is a correct answer
24 Correct 24 ms 47284 KB n = 10, 336 is a correct answer
25 Correct 24 ms 47180 KB n = 10, 438 is a correct answer
26 Correct 24 ms 47176 KB n = 10, 206 is a correct answer
27 Correct 27 ms 47220 KB n = 10, 636 is a correct answer
28 Correct 25 ms 47188 KB n = 4, 2399 is a correct answer
29 Correct 28 ms 47260 KB n = 10, 10992 is a correct answer
30 Correct 25 ms 47196 KB n = 10, 3112 is a correct answer
31 Execution timed out 2082 ms 47176 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47188 KB n = 4, 80 is a correct answer
2 Correct 25 ms 47248 KB n = 9, 110 is a correct answer
3 Correct 24 ms 47188 KB n = 4, 21 is a correct answer
4 Correct 25 ms 47188 KB n = 3, 4 is a correct answer
5 Correct 29 ms 47144 KB n = 2, 62 is a correct answer
6 Correct 23 ms 47188 KB n = 2, 3 is a correct answer
7 Correct 24 ms 47164 KB n = 3, 29 is a correct answer
8 Correct 25 ms 47216 KB n = 2, 3 is a correct answer
9 Correct 27 ms 47176 KB n = 2, 3 is a correct answer
10 Correct 24 ms 47260 KB n = 2, 2000000001 is a correct answer
11 Correct 26 ms 47188 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 47252 KB n = 3, 3000000000 is a correct answer
13 Correct 26 ms 47188 KB n = 3, 3000000000 is a correct answer
14 Correct 25 ms 47188 KB n = 4, 3000000001 is a correct answer
15 Correct 24 ms 47264 KB n = 4, 4000000000 is a correct answer
16 Correct 23 ms 47164 KB n = 5, 4000000000 is a correct answer
17 Correct 24 ms 47276 KB n = 10, 1000000343 is a correct answer
18 Correct 26 ms 47188 KB n = 10, 3189 is a correct answer
19 Correct 23 ms 47272 KB n = 10, 7000000000 is a correct answer
20 Correct 23 ms 47276 KB n = 5, 12 is a correct answer
21 Correct 23 ms 47188 KB n = 5, 25 is a correct answer
22 Correct 25 ms 47244 KB n = 2, 122 is a correct answer
23 Correct 25 ms 47188 KB n = 10, 117 is a correct answer
24 Correct 24 ms 47284 KB n = 10, 336 is a correct answer
25 Correct 24 ms 47180 KB n = 10, 438 is a correct answer
26 Correct 24 ms 47176 KB n = 10, 206 is a correct answer
27 Correct 27 ms 47220 KB n = 10, 636 is a correct answer
28 Correct 25 ms 47188 KB n = 4, 2399 is a correct answer
29 Correct 28 ms 47260 KB n = 10, 10992 is a correct answer
30 Correct 25 ms 47196 KB n = 10, 3112 is a correct answer
31 Execution timed out 2082 ms 47176 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47188 KB n = 4, 80 is a correct answer
2 Correct 25 ms 47248 KB n = 9, 110 is a correct answer
3 Correct 24 ms 47188 KB n = 4, 21 is a correct answer
4 Correct 25 ms 47188 KB n = 3, 4 is a correct answer
5 Correct 29 ms 47144 KB n = 2, 62 is a correct answer
6 Correct 23 ms 47188 KB n = 2, 3 is a correct answer
7 Correct 24 ms 47164 KB n = 3, 29 is a correct answer
8 Correct 25 ms 47216 KB n = 2, 3 is a correct answer
9 Correct 27 ms 47176 KB n = 2, 3 is a correct answer
10 Correct 24 ms 47260 KB n = 2, 2000000001 is a correct answer
11 Correct 26 ms 47188 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 47252 KB n = 3, 3000000000 is a correct answer
13 Correct 26 ms 47188 KB n = 3, 3000000000 is a correct answer
14 Correct 25 ms 47188 KB n = 4, 3000000001 is a correct answer
15 Correct 24 ms 47264 KB n = 4, 4000000000 is a correct answer
16 Correct 23 ms 47164 KB n = 5, 4000000000 is a correct answer
17 Correct 24 ms 47276 KB n = 10, 1000000343 is a correct answer
18 Correct 26 ms 47188 KB n = 10, 3189 is a correct answer
19 Correct 23 ms 47272 KB n = 10, 7000000000 is a correct answer
20 Correct 23 ms 47276 KB n = 5, 12 is a correct answer
21 Correct 23 ms 47188 KB n = 5, 25 is a correct answer
22 Correct 25 ms 47244 KB n = 2, 122 is a correct answer
23 Correct 25 ms 47188 KB n = 10, 117 is a correct answer
24 Correct 24 ms 47284 KB n = 10, 336 is a correct answer
25 Correct 24 ms 47180 KB n = 10, 438 is a correct answer
26 Correct 24 ms 47176 KB n = 10, 206 is a correct answer
27 Correct 27 ms 47220 KB n = 10, 636 is a correct answer
28 Correct 25 ms 47188 KB n = 4, 2399 is a correct answer
29 Correct 28 ms 47260 KB n = 10, 10992 is a correct answer
30 Correct 25 ms 47196 KB n = 10, 3112 is a correct answer
31 Execution timed out 2082 ms 47176 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47188 KB n = 4, 80 is a correct answer
2 Correct 25 ms 47248 KB n = 9, 110 is a correct answer
3 Correct 24 ms 47188 KB n = 4, 21 is a correct answer
4 Correct 25 ms 47188 KB n = 3, 4 is a correct answer
5 Correct 29 ms 47144 KB n = 2, 62 is a correct answer
6 Correct 23 ms 47188 KB n = 2, 3 is a correct answer
7 Correct 24 ms 47164 KB n = 3, 29 is a correct answer
8 Correct 25 ms 47216 KB n = 2, 3 is a correct answer
9 Correct 27 ms 47176 KB n = 2, 3 is a correct answer
10 Correct 24 ms 47260 KB n = 2, 2000000001 is a correct answer
11 Correct 26 ms 47188 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 47252 KB n = 3, 3000000000 is a correct answer
13 Correct 26 ms 47188 KB n = 3, 3000000000 is a correct answer
14 Correct 25 ms 47188 KB n = 4, 3000000001 is a correct answer
15 Correct 24 ms 47264 KB n = 4, 4000000000 is a correct answer
16 Correct 23 ms 47164 KB n = 5, 4000000000 is a correct answer
17 Correct 24 ms 47276 KB n = 10, 1000000343 is a correct answer
18 Correct 26 ms 47188 KB n = 10, 3189 is a correct answer
19 Correct 23 ms 47272 KB n = 10, 7000000000 is a correct answer
20 Correct 23 ms 47276 KB n = 5, 12 is a correct answer
21 Correct 23 ms 47188 KB n = 5, 25 is a correct answer
22 Correct 25 ms 47244 KB n = 2, 122 is a correct answer
23 Correct 25 ms 47188 KB n = 10, 117 is a correct answer
24 Correct 24 ms 47284 KB n = 10, 336 is a correct answer
25 Correct 24 ms 47180 KB n = 10, 438 is a correct answer
26 Correct 24 ms 47176 KB n = 10, 206 is a correct answer
27 Correct 27 ms 47220 KB n = 10, 636 is a correct answer
28 Correct 25 ms 47188 KB n = 4, 2399 is a correct answer
29 Correct 28 ms 47260 KB n = 10, 10992 is a correct answer
30 Correct 25 ms 47196 KB n = 10, 3112 is a correct answer
31 Execution timed out 2082 ms 47176 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47188 KB n = 4, 80 is a correct answer
2 Correct 25 ms 47248 KB n = 9, 110 is a correct answer
3 Correct 24 ms 47188 KB n = 4, 21 is a correct answer
4 Correct 25 ms 47188 KB n = 3, 4 is a correct answer
5 Correct 29 ms 47144 KB n = 2, 62 is a correct answer
6 Correct 23 ms 47188 KB n = 2, 3 is a correct answer
7 Correct 24 ms 47164 KB n = 3, 29 is a correct answer
8 Correct 25 ms 47216 KB n = 2, 3 is a correct answer
9 Correct 27 ms 47176 KB n = 2, 3 is a correct answer
10 Correct 24 ms 47260 KB n = 2, 2000000001 is a correct answer
11 Correct 26 ms 47188 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 47252 KB n = 3, 3000000000 is a correct answer
13 Correct 26 ms 47188 KB n = 3, 3000000000 is a correct answer
14 Correct 25 ms 47188 KB n = 4, 3000000001 is a correct answer
15 Correct 24 ms 47264 KB n = 4, 4000000000 is a correct answer
16 Correct 23 ms 47164 KB n = 5, 4000000000 is a correct answer
17 Correct 24 ms 47276 KB n = 10, 1000000343 is a correct answer
18 Correct 26 ms 47188 KB n = 10, 3189 is a correct answer
19 Correct 23 ms 47272 KB n = 10, 7000000000 is a correct answer
20 Correct 23 ms 47276 KB n = 5, 12 is a correct answer
21 Correct 23 ms 47188 KB n = 5, 25 is a correct answer
22 Correct 25 ms 47244 KB n = 2, 122 is a correct answer
23 Correct 25 ms 47188 KB n = 10, 117 is a correct answer
24 Correct 24 ms 47284 KB n = 10, 336 is a correct answer
25 Correct 24 ms 47180 KB n = 10, 438 is a correct answer
26 Correct 24 ms 47176 KB n = 10, 206 is a correct answer
27 Correct 27 ms 47220 KB n = 10, 636 is a correct answer
28 Correct 25 ms 47188 KB n = 4, 2399 is a correct answer
29 Correct 28 ms 47260 KB n = 10, 10992 is a correct answer
30 Correct 25 ms 47196 KB n = 10, 3112 is a correct answer
31 Execution timed out 2082 ms 47176 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47188 KB n = 4, 80 is a correct answer
2 Correct 25 ms 47248 KB n = 9, 110 is a correct answer
3 Correct 24 ms 47188 KB n = 4, 21 is a correct answer
4 Correct 25 ms 47188 KB n = 3, 4 is a correct answer
5 Correct 29 ms 47144 KB n = 2, 62 is a correct answer
6 Correct 23 ms 47188 KB n = 2, 3 is a correct answer
7 Correct 24 ms 47164 KB n = 3, 29 is a correct answer
8 Correct 25 ms 47216 KB n = 2, 3 is a correct answer
9 Correct 27 ms 47176 KB n = 2, 3 is a correct answer
10 Correct 24 ms 47260 KB n = 2, 2000000001 is a correct answer
11 Correct 26 ms 47188 KB n = 2, 3000000000 is a correct answer
12 Correct 24 ms 47252 KB n = 3, 3000000000 is a correct answer
13 Correct 26 ms 47188 KB n = 3, 3000000000 is a correct answer
14 Correct 25 ms 47188 KB n = 4, 3000000001 is a correct answer
15 Correct 24 ms 47264 KB n = 4, 4000000000 is a correct answer
16 Correct 23 ms 47164 KB n = 5, 4000000000 is a correct answer
17 Correct 24 ms 47276 KB n = 10, 1000000343 is a correct answer
18 Correct 26 ms 47188 KB n = 10, 3189 is a correct answer
19 Correct 23 ms 47272 KB n = 10, 7000000000 is a correct answer
20 Correct 23 ms 47276 KB n = 5, 12 is a correct answer
21 Correct 23 ms 47188 KB n = 5, 25 is a correct answer
22 Correct 25 ms 47244 KB n = 2, 122 is a correct answer
23 Correct 25 ms 47188 KB n = 10, 117 is a correct answer
24 Correct 24 ms 47284 KB n = 10, 336 is a correct answer
25 Correct 24 ms 47180 KB n = 10, 438 is a correct answer
26 Correct 24 ms 47176 KB n = 10, 206 is a correct answer
27 Correct 27 ms 47220 KB n = 10, 636 is a correct answer
28 Correct 25 ms 47188 KB n = 4, 2399 is a correct answer
29 Correct 28 ms 47260 KB n = 10, 10992 is a correct answer
30 Correct 25 ms 47196 KB n = 10, 3112 is a correct answer
31 Execution timed out 2082 ms 47176 KB Time limit exceeded
32 Halted 0 ms 0 KB -