Submission #787778

# Submission time Handle Problem Language Result Execution time Memory
787778 2023-07-19T12:35:14 Z fatemetmhr Shortcut (IOI16_shortcut) C++17
0 / 100
2 ms 380 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;
    for(int i = 0; i < n; i++)
        av.insert({dis[i], i});
    for(int i = 0; i < n; i++){
        if(av.empty())
            exit(0);
        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;
     if(n > 10)
        exit(0);
    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 x = 0; x < n; x++){
            bfs(x);
            for(int k = 0; k < n; k++) if(k != x)
                mx = max(mx, dis[k] + d[k] + d[x]);
        }
        adj[i].pop_back();
        adj[j].pop_back();
        mn = min(mn, mx);
    }
    return mn;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 380 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 Correct 1 ms 340 KB n = 2, 62 is a correct answer
6 Correct 0 ms 340 KB n = 2, 3 is a correct answer
7 Correct 0 ms 340 KB n = 3, 29 is a correct answer
8 Correct 0 ms 340 KB n = 2, 3 is a correct answer
9 Correct 0 ms 340 KB n = 2, 3 is a correct answer
10 Correct 1 ms 340 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 340 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 340 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 340 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 340 KB n = 5, 4000000000 is a correct answer
17 Correct 2 ms 380 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 340 KB n = 10, 3189 is a correct answer
19 Correct 2 ms 340 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 340 KB n = 5, 12 is a correct answer
21 Correct 1 ms 340 KB n = 5, 25 is a correct answer
22 Correct 1 ms 340 KB n = 2, 122 is a correct answer
23 Correct 2 ms 340 KB n = 10, 117 is a correct answer
24 Correct 2 ms 340 KB n = 10, 336 is a correct answer
25 Correct 1 ms 340 KB n = 10, 438 is a correct answer
26 Correct 2 ms 340 KB n = 10, 206 is a correct answer
27 Correct 2 ms 380 KB n = 10, 636 is a correct answer
28 Correct 0 ms 340 KB n = 4, 2399 is a correct answer
29 Correct 2 ms 344 KB n = 10, 10992 is a correct answer
30 Correct 2 ms 340 KB n = 10, 3112 is a correct answer
31 Incorrect 0 ms 340 KB Secret is incorrect!
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 380 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 Correct 1 ms 340 KB n = 2, 62 is a correct answer
6 Correct 0 ms 340 KB n = 2, 3 is a correct answer
7 Correct 0 ms 340 KB n = 3, 29 is a correct answer
8 Correct 0 ms 340 KB n = 2, 3 is a correct answer
9 Correct 0 ms 340 KB n = 2, 3 is a correct answer
10 Correct 1 ms 340 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 340 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 340 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 340 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 340 KB n = 5, 4000000000 is a correct answer
17 Correct 2 ms 380 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 340 KB n = 10, 3189 is a correct answer
19 Correct 2 ms 340 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 340 KB n = 5, 12 is a correct answer
21 Correct 1 ms 340 KB n = 5, 25 is a correct answer
22 Correct 1 ms 340 KB n = 2, 122 is a correct answer
23 Correct 2 ms 340 KB n = 10, 117 is a correct answer
24 Correct 2 ms 340 KB n = 10, 336 is a correct answer
25 Correct 1 ms 340 KB n = 10, 438 is a correct answer
26 Correct 2 ms 340 KB n = 10, 206 is a correct answer
27 Correct 2 ms 380 KB n = 10, 636 is a correct answer
28 Correct 0 ms 340 KB n = 4, 2399 is a correct answer
29 Correct 2 ms 344 KB n = 10, 10992 is a correct answer
30 Correct 2 ms 340 KB n = 10, 3112 is a correct answer
31 Incorrect 0 ms 340 KB Secret is incorrect!
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 380 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 Correct 1 ms 340 KB n = 2, 62 is a correct answer
6 Correct 0 ms 340 KB n = 2, 3 is a correct answer
7 Correct 0 ms 340 KB n = 3, 29 is a correct answer
8 Correct 0 ms 340 KB n = 2, 3 is a correct answer
9 Correct 0 ms 340 KB n = 2, 3 is a correct answer
10 Correct 1 ms 340 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 340 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 340 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 340 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 340 KB n = 5, 4000000000 is a correct answer
17 Correct 2 ms 380 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 340 KB n = 10, 3189 is a correct answer
19 Correct 2 ms 340 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 340 KB n = 5, 12 is a correct answer
21 Correct 1 ms 340 KB n = 5, 25 is a correct answer
22 Correct 1 ms 340 KB n = 2, 122 is a correct answer
23 Correct 2 ms 340 KB n = 10, 117 is a correct answer
24 Correct 2 ms 340 KB n = 10, 336 is a correct answer
25 Correct 1 ms 340 KB n = 10, 438 is a correct answer
26 Correct 2 ms 340 KB n = 10, 206 is a correct answer
27 Correct 2 ms 380 KB n = 10, 636 is a correct answer
28 Correct 0 ms 340 KB n = 4, 2399 is a correct answer
29 Correct 2 ms 344 KB n = 10, 10992 is a correct answer
30 Correct 2 ms 340 KB n = 10, 3112 is a correct answer
31 Incorrect 0 ms 340 KB Secret is incorrect!
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 380 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 Correct 1 ms 340 KB n = 2, 62 is a correct answer
6 Correct 0 ms 340 KB n = 2, 3 is a correct answer
7 Correct 0 ms 340 KB n = 3, 29 is a correct answer
8 Correct 0 ms 340 KB n = 2, 3 is a correct answer
9 Correct 0 ms 340 KB n = 2, 3 is a correct answer
10 Correct 1 ms 340 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 340 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 340 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 340 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 340 KB n = 5, 4000000000 is a correct answer
17 Correct 2 ms 380 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 340 KB n = 10, 3189 is a correct answer
19 Correct 2 ms 340 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 340 KB n = 5, 12 is a correct answer
21 Correct 1 ms 340 KB n = 5, 25 is a correct answer
22 Correct 1 ms 340 KB n = 2, 122 is a correct answer
23 Correct 2 ms 340 KB n = 10, 117 is a correct answer
24 Correct 2 ms 340 KB n = 10, 336 is a correct answer
25 Correct 1 ms 340 KB n = 10, 438 is a correct answer
26 Correct 2 ms 340 KB n = 10, 206 is a correct answer
27 Correct 2 ms 380 KB n = 10, 636 is a correct answer
28 Correct 0 ms 340 KB n = 4, 2399 is a correct answer
29 Correct 2 ms 344 KB n = 10, 10992 is a correct answer
30 Correct 2 ms 340 KB n = 10, 3112 is a correct answer
31 Incorrect 0 ms 340 KB Secret is incorrect!
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 380 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 Correct 1 ms 340 KB n = 2, 62 is a correct answer
6 Correct 0 ms 340 KB n = 2, 3 is a correct answer
7 Correct 0 ms 340 KB n = 3, 29 is a correct answer
8 Correct 0 ms 340 KB n = 2, 3 is a correct answer
9 Correct 0 ms 340 KB n = 2, 3 is a correct answer
10 Correct 1 ms 340 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 340 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 340 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 340 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 340 KB n = 5, 4000000000 is a correct answer
17 Correct 2 ms 380 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 340 KB n = 10, 3189 is a correct answer
19 Correct 2 ms 340 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 340 KB n = 5, 12 is a correct answer
21 Correct 1 ms 340 KB n = 5, 25 is a correct answer
22 Correct 1 ms 340 KB n = 2, 122 is a correct answer
23 Correct 2 ms 340 KB n = 10, 117 is a correct answer
24 Correct 2 ms 340 KB n = 10, 336 is a correct answer
25 Correct 1 ms 340 KB n = 10, 438 is a correct answer
26 Correct 2 ms 340 KB n = 10, 206 is a correct answer
27 Correct 2 ms 380 KB n = 10, 636 is a correct answer
28 Correct 0 ms 340 KB n = 4, 2399 is a correct answer
29 Correct 2 ms 344 KB n = 10, 10992 is a correct answer
30 Correct 2 ms 340 KB n = 10, 3112 is a correct answer
31 Incorrect 0 ms 340 KB Secret is incorrect!
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 380 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 Correct 1 ms 340 KB n = 2, 62 is a correct answer
6 Correct 0 ms 340 KB n = 2, 3 is a correct answer
7 Correct 0 ms 340 KB n = 3, 29 is a correct answer
8 Correct 0 ms 340 KB n = 2, 3 is a correct answer
9 Correct 0 ms 340 KB n = 2, 3 is a correct answer
10 Correct 1 ms 340 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 340 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 340 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 340 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 340 KB n = 5, 4000000000 is a correct answer
17 Correct 2 ms 380 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 340 KB n = 10, 3189 is a correct answer
19 Correct 2 ms 340 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 340 KB n = 5, 12 is a correct answer
21 Correct 1 ms 340 KB n = 5, 25 is a correct answer
22 Correct 1 ms 340 KB n = 2, 122 is a correct answer
23 Correct 2 ms 340 KB n = 10, 117 is a correct answer
24 Correct 2 ms 340 KB n = 10, 336 is a correct answer
25 Correct 1 ms 340 KB n = 10, 438 is a correct answer
26 Correct 2 ms 340 KB n = 10, 206 is a correct answer
27 Correct 2 ms 380 KB n = 10, 636 is a correct answer
28 Correct 0 ms 340 KB n = 4, 2399 is a correct answer
29 Correct 2 ms 344 KB n = 10, 10992 is a correct answer
30 Correct 2 ms 340 KB n = 10, 3112 is a correct answer
31 Incorrect 0 ms 340 KB Secret is incorrect!
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 380 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 Correct 1 ms 340 KB n = 2, 62 is a correct answer
6 Correct 0 ms 340 KB n = 2, 3 is a correct answer
7 Correct 0 ms 340 KB n = 3, 29 is a correct answer
8 Correct 0 ms 340 KB n = 2, 3 is a correct answer
9 Correct 0 ms 340 KB n = 2, 3 is a correct answer
10 Correct 1 ms 340 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 340 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 340 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 340 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 340 KB n = 5, 4000000000 is a correct answer
17 Correct 2 ms 380 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 340 KB n = 10, 3189 is a correct answer
19 Correct 2 ms 340 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 340 KB n = 5, 12 is a correct answer
21 Correct 1 ms 340 KB n = 5, 25 is a correct answer
22 Correct 1 ms 340 KB n = 2, 122 is a correct answer
23 Correct 2 ms 340 KB n = 10, 117 is a correct answer
24 Correct 2 ms 340 KB n = 10, 336 is a correct answer
25 Correct 1 ms 340 KB n = 10, 438 is a correct answer
26 Correct 2 ms 340 KB n = 10, 206 is a correct answer
27 Correct 2 ms 380 KB n = 10, 636 is a correct answer
28 Correct 0 ms 340 KB n = 4, 2399 is a correct answer
29 Correct 2 ms 344 KB n = 10, 10992 is a correct answer
30 Correct 2 ms 340 KB n = 10, 3112 is a correct answer
31 Incorrect 0 ms 340 KB Secret is incorrect!
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB n = 4, 80 is a correct answer
2 Correct 1 ms 380 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 Correct 1 ms 340 KB n = 2, 62 is a correct answer
6 Correct 0 ms 340 KB n = 2, 3 is a correct answer
7 Correct 0 ms 340 KB n = 3, 29 is a correct answer
8 Correct 0 ms 340 KB n = 2, 3 is a correct answer
9 Correct 0 ms 340 KB n = 2, 3 is a correct answer
10 Correct 1 ms 340 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 340 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 340 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 340 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 340 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 340 KB n = 5, 4000000000 is a correct answer
17 Correct 2 ms 380 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 340 KB n = 10, 3189 is a correct answer
19 Correct 2 ms 340 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 340 KB n = 5, 12 is a correct answer
21 Correct 1 ms 340 KB n = 5, 25 is a correct answer
22 Correct 1 ms 340 KB n = 2, 122 is a correct answer
23 Correct 2 ms 340 KB n = 10, 117 is a correct answer
24 Correct 2 ms 340 KB n = 10, 336 is a correct answer
25 Correct 1 ms 340 KB n = 10, 438 is a correct answer
26 Correct 2 ms 340 KB n = 10, 206 is a correct answer
27 Correct 2 ms 380 KB n = 10, 636 is a correct answer
28 Correct 0 ms 340 KB n = 4, 2399 is a correct answer
29 Correct 2 ms 344 KB n = 10, 10992 is a correct answer
30 Correct 2 ms 340 KB n = 10, 3112 is a correct answer
31 Incorrect 0 ms 340 KB Secret is incorrect!
32 Halted 0 ms 0 KB -