Submission #187248

# Submission time Handle Problem Language Result Execution time Memory
187248 2020-01-12T14:49:05 Z PedroBigMan Shortcut (IOI16_shortcut) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include "shortcut.h"
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF 100000000000000000LL
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}

class WG //everything works for weighted directed graphs
{
    public:
    ll N; vector<vector<pl> > adj;
    vector<ll> pr; 
    
    WG(vector<vector<pl> > ad)
    {
        adj=ad; N=adj.size();
        REP(i,0,N) {pr.pb(false);}
    }
    
    void Reset()
    {
        REP(i,0,N) {pr[i]=false;}
    }
    
    vector<ll> Djikstra(ll s)
    {
        Reset();
        vector<ll> d; REP(i,0,N) {d.pb(INF);}
        d[s]=0;
        priority_queue<pl> q;
        q.push(mp(0,s));
        ll cur;
        while(!q.empty())
        {
            cur=q.top().ss; q.pop();
            if(pr[cur]) {continue;}
            pr[cur]=true; 
            REP(i,0,adj[cur].size())
            {
                if(d[adj[cur][i].ff]>d[cur]+adj[cur][i].ss)
                {
                    d[adj[cur][i].ff]=d[cur]+adj[cur][i].ss;
                    q.push(mp(-d[adj[cur][i].ff],adj[cur][i].ff));
                }
            }
        }
        return d;
    }
};

ll find_shortcut(int n, std::vector<int> lll, std::vector<int> ddd, int ccc)
{
    ll N=(ll) n; ll c=(ll) ccc;
    vector<ll> l,r; 
    REP(i,0,lll.size()) {l.pb((ll) lll[i]);} 
    REP(i,0,ddd.size()) {r.pb((ll) ddd[i]);}
    vector<vector<pl> > adj; vector<pl> xx; REP(i,0,2*N) {adj.pb(xx);}
    REP(i,0,l.size())
    {
        adj[i].pb(mp(i+1,l[i]));
        adj[i+1].pb(mp(i,l[i]));
    }
    REP(i,0,r.size())
    {
        adj[i].pb(mp(N+i,r[i]));
        adj[N+i].pb(mp(i,r[i]));
    }
    WG G(adj);
    ll ans=INF;
    REP(a,0,N)
    {
        REP(b,a+1,N)
        {
            G.adj[a].pb(mp(b,c));
            G.adj[b].pb(mp(a,c));
            vector<ll> d=G.Djikstra(0);
            ll mav=-INF; ll ind=0;
            REP(i,1,2*N) {if(d[i]>mav) {mav=d[i]; ind=i;}}
            d.clear();
            d=G.Djikstra(ind);
            mav=-INF; ll ind=0;
            REP(i,1,2*N) {if(d[i]>mav) {mav=d[i]; ind=i;}}
            ans=min(ans,mav);
            G.adj[a].pop_back();
            G.adj[b].pop_back();
        }
    }
    return ans;
}

Compilation message

shortcut.cpp: In function 'void Out(std::vector<long long int>)':
shortcut.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
shortcut.cpp:24:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
shortcut.cpp:24:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
shortcut.cpp: In member function 'std::vector<long long int> WG::Djikstra(ll)':
shortcut.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
shortcut.cpp:56:17:
             REP(i,0,adj[cur].size())
                 ~~~~~~~~~~~~~~~~~~~
shortcut.cpp:56:13: note: in expansion of macro 'REP'
             REP(i,0,adj[cur].size())
             ^~~
shortcut.cpp: In function 'll find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
shortcut.cpp:73:9:
     REP(i,0,lll.size()) {l.pb((ll) lll[i]);} 
         ~~~~~~~~~~~~~~           
shortcut.cpp:73:5: note: in expansion of macro 'REP'
     REP(i,0,lll.size()) {l.pb((ll) lll[i]);} 
     ^~~
shortcut.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
shortcut.cpp:74:9:
     REP(i,0,ddd.size()) {r.pb((ll) ddd[i]);}
         ~~~~~~~~~~~~~~           
shortcut.cpp:74:5: note: in expansion of macro 'REP'
     REP(i,0,ddd.size()) {r.pb((ll) ddd[i]);}
     ^~~
shortcut.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
shortcut.cpp:76:9:
     REP(i,0,l.size())
         ~~~~~~~~~~~~             
shortcut.cpp:76:5: note: in expansion of macro 'REP'
     REP(i,0,l.size())
     ^~~
shortcut.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
shortcut.cpp:81:9:
     REP(i,0,r.size())
         ~~~~~~~~~~~~             
shortcut.cpp:81:5: note: in expansion of macro 'REP'
     REP(i,0,r.size())
     ^~~
shortcut.cpp:99:26: error: redeclaration of 'll ind'
             mav=-INF; ll ind=0;
                          ^~~
shortcut.cpp:95:29: note: 'll ind' previously declared here
             ll mav=-INF; ll ind=0;
                             ^~~