Submission #1069912

#TimeUsernameProblemLanguageResultExecution timeMemory
1069912TheQuantiXShortcut (IOI16_shortcut)C++17
31 / 100
2051 ms26972 KiB
#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; }

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...