답안 #787451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787451 2023-07-19T08:06:21 Z fatemetmhr Shortcut (IOI16_shortcut) C++17
0 / 100
1 ms 340 KB
//  ~ Be Name Khoda ~  //

#include "shortcut.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")

using namespace std;

typedef long long ll;

#define pb       push_back
#define mp       make_pair
#define all(x)   x.begin(), x.end()
#define fi       first
#define se       second

const int maxn  =  1e6   + 10;
const int maxn5 =  3e3   + 10;
const int maxnt =  1.2e6 + 10;
const int maxn3 =  1e3   + 10;
const int mod   =  1e9   + 7;
const int lg    =  20;
const ll  inf   =  1e18;

int n;
ll c;
vector <ll> d;
ll ps[maxn5], ps2[maxn5], dis[maxn5];
set <pair<ll, int>> av;
vector <pair<int, ll>> adj[maxn5];

void bfs(int rt){
    fill(dis, dis + n, inf);
    av.clear();
    dis[rt] = 0;
    av.insert({0, rt});
    while(av.size()){
        int v = av.begin()->se;
        av.erase(av.begin());
        for(auto [u, l] : adj[v]) if(dis[u] > dis[v] + l){
            av.erase({dis[u], u});
            dis[u] = dis[v] + l;
            av.insert({dis[u], u});
        }
    }
}

long long find_shortcut(int N, std::vector<int> l, std::vector<int> D, int C)
{
    n = N;
    c = C;
    for(auto u : D)
        d.pb(u);
    for(int i = 1; i < n; i++){
        adj[i].pb({i - 1, l[i - 1]});
        adj[i - 1].pb({i, l[i - 1]});
    }
    ll mn = inf;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
        adj[i].pb({j, c});
        adj[j].pb({i, c});
        ll mx = 0;
        for(int j = 0; j < n; j++){
            bfs(j);
            for(int k = 0; k < n; k++)
                mx = max(mx, dis[k] + d[k] + d[j]);
        }
        adj[i].pop_back();
        adj[j].pop_back();
        mn = min(mn, mx);
    }
    return mn;
}

















# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 340 KB n = 9, 110 is a correct answer
3 Correct 0 ms 340 KB n = 4, 21 is a correct answer
4 Correct 1 ms 340 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 340 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 340 KB n = 9, 110 is a correct answer
3 Correct 0 ms 340 KB n = 4, 21 is a correct answer
4 Correct 1 ms 340 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 340 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 340 KB n = 9, 110 is a correct answer
3 Correct 0 ms 340 KB n = 4, 21 is a correct answer
4 Correct 1 ms 340 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 340 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 340 KB n = 9, 110 is a correct answer
3 Correct 0 ms 340 KB n = 4, 21 is a correct answer
4 Correct 1 ms 340 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 340 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 340 KB n = 9, 110 is a correct answer
3 Correct 0 ms 340 KB n = 4, 21 is a correct answer
4 Correct 1 ms 340 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 340 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 340 KB n = 9, 110 is a correct answer
3 Correct 0 ms 340 KB n = 4, 21 is a correct answer
4 Correct 1 ms 340 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 340 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 340 KB n = 9, 110 is a correct answer
3 Correct 0 ms 340 KB n = 4, 21 is a correct answer
4 Correct 1 ms 340 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 340 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 340 KB n = 9, 110 is a correct answer
3 Correct 0 ms 340 KB n = 4, 21 is a correct answer
4 Correct 1 ms 340 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 340 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -