이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
int n;
vector<ll> x;
bool solve(vector<tuple<ll, ll, ll>> sq){
ll x1 = -INF, y1 = -INF, x2 = INF, y2 = INF;
for(auto [xc, yc, r] : sq){
x1 = max(x1, xc-r);
x2 = min(x2, xc+r);
y1 = max(y1, yc-r);
y2 = min(y2, yc+r);
}
if(x1 > x2 || y1 > y2) return false;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(x[i]-x[j] >= x1-y2 && x[i]-x[j] <= x2-y1 && x[i]+x[j] <= x2+y2 && x[i]+x[j] >= x1+y1){
return true;
}
}
}
return false;
}
ll find_shortcut(int n_, vector<int> len, vector<int> d, int c) {
n = n_;
x.resize(n);
x[0] = 0;
for(int i = 0; i < n-1; i++) x[i+1] = x[i]+len[i];
ll M = x.back()+*max_element(d.begin(), d.end())*2;
ll lo = 0, hi = M;
for(ll mid=(lo+hi)/2; lo<hi; mid=(lo+hi)/2){
vector<tuple<ll, ll, ll>> sq;
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
if(abs(x[i]-x[j])+d[i]+d[j] <= mid) continue;
sq.emplace_back(x[i], x[j], mid-c-d[i]-d[j]);
}
}
if(solve(sq)) hi = mid;
else lo = mid+1;
}
return lo;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |