Submission #729055

# Submission time Handle Problem Language Result Execution time Memory
729055 2023-04-23T12:58:53 Z grogu Shortcut (IOI16_shortcut) C++14
Compilation error
0 ms 0 KB
#include "shortcut.h"
#include <bits/stdc++.h>
#define endl '\n'
#define here cerr<<"=========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define ll int
#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
**/

Compilation message

shortcut.cpp: In function 'int naj(int)':
shortcut.cpp:13:15: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000' to '-1530494976' [-Woverflow]
   13 | #define llinf 1000000000000000LL
      |               ^~~~~~~~~~~~~~~~~~
shortcut.cpp:22:39: note: in expansion of macro 'llinf'
   22 |     for(ll i = 0;i<=tsz;i++) dis[i] = llinf;
      |                                       ^~~~~
shortcut.cpp: At global scope:
shortcut.cpp:44:4: error: ambiguating new declaration of 'int find_shortcut(int, std::vector<int>, std::vector<int>, int)'
   44 | ll find_shortcut(int N, vector<int> L, vector<int> D, int C)
      |    ^~~~~~~~~~~~~
In file included from shortcut.cpp:1:
shortcut.h:4:11: note: old declaration 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)'
    4 | long long find_shortcut(int n, std::vector <int> l, std::vector <int> d, int c);
      |           ^~~~~~~~~~~~~
shortcut.cpp: In function 'int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:13:15: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000' to '-1530494976' [-Woverflow]
   13 | #define llinf 1000000000000000LL
      |               ^~~~~~~~~~~~~~~~~~
shortcut.cpp:57:14: note: in expansion of macro 'llinf'
   57 |     ll ans = llinf;
      |              ^~~~~