답안 #787560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787560 2023-07-19T09:42:22 Z NothingXD Shortcut (IOI16_shortcut) C++17
0 / 100
47 ms 8140 KB
#include "shortcut.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;

void debug_out(){cerr << endl;}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e6 + 10;
const ll inf = 1e18;

int n, l[maxn], d[maxn], st, en, c;
ll h[maxn];

void bfs(int v){
	memset(h, 63, sizeof h);
	h[v] = 0;
	queue<int> q;
	q.push(v);
	while(!q.empty()){
		int v = q.front();
		q.pop();
		if (v && h[v-1] > h[v] + l[v-1]){
			h[v-1] = h[v] + l[v-1];
			q.push(v-1);
		}
		if (v < n-1 && h[v+1] > h[v] + l[v]){
			h[v+1] = h[v] + l[v];
			q.push(v+1);
		}
		if (v == st && h[en] > h[st] + c){
			h[en] = h[st] + c;
			q.push(en);
		}
		if (v == en && h[st] > h[en] + c){
			h[st] = h[en] + c;
			q.push(st);
		}
	}
}


long long find_shortcut(int N, std::vector<int> L, std::vector<int> D, int C){

	n = N, c = C;
	for (int i = 0; i < n; i++){
		if (i != n-1) l[i] = L[i];
		d[i] = D[i];
	}

	ll ans = inf;

	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			st = i;
			en = j;
			ll res = 0;
			for (int k = 0; k < n; k++){
				bfs(k);
				for (int l = 0; l < n; l++){
					res = max(res, h[l] + d[l] + d[k]);
				}
			}
			ans = min(ans, res);
		}
	}

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