Submission #1367600

#TimeUsernameProblemLanguageResultExecution timeMemory
1367600weedywelonShortcut (IOI16_shortcut)C++20
Compilation error
0 ms0 KiB
#include "shortcut.h"
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <deque>
#include <map>
#include <chrono>
#include <random>
#include <bitset>
#include <tuple>
#define SZ(x) int(x.size())
#define FR(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,n) FR(i,0,n)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define A first
#define B second
#define mp(a,b) make_pair(a,b)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef unsigned __int128 U128;
typedef __int128 I128;
typedef std::pair<int,int> PII;
typedef std::pair<LL,LL> PLL;
using namespace std;

LL find_shortcut(int N, vector<int> l, vector<int> d, int c){
	LL n=N;
	vector<pair<PLL,LL> > adj[2*n+1];
	FOR(i,n){
		if (i<n-1) adj[i].push_back(mp(mp(i+1, l[i]),0));
		if (i>0) adj[i].push_back(mp(mp(i-1, l[i-1]),0));
		adj[i].push_back(mp(mp(i+n, d[i]),0));
		adj[i+n].push_back(mp(mp(i, d[i]),0));
	}
	
	LL ans=1e18;
	FOR(i,n) FR(j,i+1,n){
		LL tmp=0;
		FOR(s,2*n){
			LL dist[2*n+1];
			memset(dist,-1,sizeof(dist));
			priority_queue<PLL,vector<PLL>, greater<PLL> > pq;
			pq.push(mp(0,s));
			dist[s]=0;
			
			while (!pq.empty()){
				LL d=pq.top().A, u=pq.top().B;
				pq.pop();
				if (dist[u]!=d) continue;
				
				for (pair<PLL,LL> p:adj[u]){
					LL v=p.A.A, w=p.A.B;
					if (dist[v]==-1 || dist[v]>d+w){
						dist[v]=d+w;
						pq.push(mp(dist[v],v));
					}
				}
				
				if (u==a){
					if (dist[b]==-1 || dist[b]>d+c){
						dist[b]=d+c;
						pq.push(mp(dist[b],b));
					}
				}
				if (u==b){
					if (dist[a]==-1 || dist[a]>d+c){
						dist[a]=d+c;
						pq.push(mp(dist[a],a));
					}
				}
			}
			
			LL mx=0;
			FOR(i,2*n) mx=max(mx,dist[i]);
			tmp=max(tmp,mx);
		}
		ans=min(ans,tmp);
	}
	return ans;
}

Compilation message (stderr)

shortcut.cpp: In function 'LL find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:72:40: error: 'a' was not declared in this scope
   72 |                                 if (u==a){
      |                                        ^
shortcut.cpp:73:50: error: 'b' was not declared in this scope
   73 |                                         if (dist[b]==-1 || dist[b]>d+c){
      |                                                  ^
shortcut.cpp:78:40: error: 'b' was not declared in this scope
   78 |                                 if (u==b){
      |                                        ^
shortcut.cpp:79:50: error: 'a' was not declared in this scope
   79 |                                         if (dist[a]==-1 || dist[a]>d+c){
      |                                                  ^