이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "shortcut.h"
using namespace std;
using ll = long long;
constexpr ll INF = 1000000000000000000LL;
ll n, m, q, k, x, y, a, b, c;
vector< pair<ll, ll> > G[1000000];
deque< pair<ll, pair<ll, ll> > > v;
vector<ll> pref;
ll diam(ll x, ll y, ll c, vector<int> &d) {
ll ans = 0;
for (int i = 0; i < v.size(); i++) {
if (v[i].first <= ans) {
break;
}
// cout << '\t' << v[i].first << ' ' << d[v[i].second.first] + d[v[i].second.second] + abs(pref[v[i].second.first] - pref[x]) + c + abs(pref[v[i].second.second] - pref[y]) << ' ' << d[v[i].second.first] + d[v[i].second.second] + abs(pref[v[i].second.first] - pref[y]) + c + abs(pref[v[i].second.second] - pref[x]) << '\n';
ans = max(ans, min({v[i].first, d[v[i].second.first] + d[v[i].second.second] + abs(pref[v[i].second.first] - pref[x]) + c + abs(pref[v[i].second.second] - pref[y]), d[v[i].second.first] + d[v[i].second.second] + abs(pref[v[i].second.first] - pref[y]) + c + abs(pref[v[i].second.second] - pref[x])}));
}
return ans;
}
long long find_shortcut(int n, vector<int> l, vector<int> d, int c) {
for (int i = 0; i < n - 1; i++) {
G[i].push_back({i + 1, l[i]});
G[i + 1].push_back({i, l[i]});
}
pref.resize(n);
for (int i = 0; i < n - 1; i++) {
pref[i + 1] = pref[i] + l[i];
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
ll dist = pref[j] - pref[i];
v.push_back({dist + d[i] + d[j], {i, j}});
}
}
sort(v.rbegin(), v.rend());
ll ans = INF;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
ll ans1 = diam(i, j, c, d);
// cout << i << ' ' << j << ' ' << ans1 << '\n';
ans = min(ans, ans1);
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
shortcut.cpp: In function 'll diam(ll, ll, ll, std::vector<int>&)':
shortcut.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for (int i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~| # | 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... |