# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
827173 | caganyanmaz | Shortcut (IOI16_shortcut) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#include "shortcut.h"
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
using namespace std;
constexpr static int MXN = 255;
constexpr static int INF = 1e16;
int pf[MXN];
vector<int> d;
int c;
static inline int get_dist(int a, int b)
{
return pf[max(a,b)] - pf[min(a,b)];
}
static inline int get_real_dist(int a, int b, int l, int r) // a <= b
{
if (a > b) swap(a, b);
return d[a] + d[b] + min(get_dist(a, b), get_dist(a, l) + get_dist(b, r) + c);
}
long long find_shortcut(int32_t n, vector<int32_t> _l, vector<int32_t> _d, int32_t _c)
{
for (int i : _d)
d.pb(i);
c = _c;
for (int i = 1; i < n; i++)
pf[i] = pf[i-1] + static_cast<int>(_l[i-1]);
int mn = 0;
for (int i = 0; i < n; i++)
for (int j = i; j < n; j++)
mn = max(mn, get_dist(i, j) + d[i] + d[j]);
debug(mn);#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#include "shortcut.h"
#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
using namespace std;
constexpr static int MXN = 255;
constexpr static int INF = 1e16;
int pf[MXN];
vector<int> d;
int c;
static inline int get_dist(int a, int b)
{
return pf[max(a,b)] - pf[min(a,b)];
}
static inline int get_real_dist(int a, int b, int l, int r) // a <= b
{
if (a > b) swap(a, b);
return d[a] + d[b] + min(get_dist(a, b), get_dist(a, l) + get_dist(b, r) + c);
}
long long find_shortcut(int32_t n, vector<int32_t> _l, vector<int32_t> _d, int32_t _c)
{
for (int i : _d)
d.pb(i);
c = _c;
for (int i = 1; i < n; i++)
pf[i] = pf[i-1] + static_cast<int>(_l[i-1]);
int mn = 0;
for (int i = 0; i < n; i++)
for (int j = i; j < n; j++)
mn = max(mn, get_dist(i, j) + d[i] + d[j]);
debug(mn);
for (int l = 0; l < n; l++)
{
for (int r = l+1; r < n; r++)
{
int mx = 0;
for (int i = 0; i < n; i++)
for (int j = i; j < n; j++)
mx = max(mx, get_real_dist(i, j, l, r));
mn = min(mn, mx);
debug(l, r, mx);
}
}
return mn;
}
for (int l = 0; l < n; l++)
{
for (int r = l+1; r < n; r++)
{
int mx = 0;
for (int i = 0; i < n; i++)
for (int j = i; j < n; j++)
mx = max(mx, get_real_dist(i, j, l, r));
mn = min(mn, mx);
debug(l, r, mx);
}
}
return mn;
}