제출 #827761

#제출 시각아이디문제언어결과실행 시간메모리
827761caganyanmazShortcut (IOI16_shortcut)C++14
71 / 100
2037 ms2640 KiB
#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 = 1e6 + 5; constexpr static int INF = 1e18; int pf[MXN]; vector<int> d, l; int c, n; static inline int dist(int a, int b) { return pf[max(a, b)] - pf[min(a, b)]; } bool check(int k) { int xl = -INF, xr = INF, yl = -INF, yr = INF; for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { if (dist(i, j) + d[i] + d[j] > k) { xl = max(xl, pf[j] + pf[i] - k + c + d[i] + d[j]); xr = min(xr, pf[j] + pf[i] + k - c - d[i] - d[j]); yl = max(yl, pf[j] - pf[i] - k + c + d[i] + d[j]); yr = min(yr, pf[j] - pf[i] + k - c - d[i] - d[j]); } } } if (xr < xl || yr < yl) return false; for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) if (pf[i] + pf[j] <= xr && pf[i] + pf[j] >= xl && pf[j] - pf[i] <= yr && pf[j] - pf[i] >= yl) return true; return false; } long long find_shortcut(int32_t _n, vector<int32_t> _l, vector<int32_t> _d, int32_t _c) { c = _c; n = _n; for (int i : _l) l.pb(i); for (int i : _d) d.pb(i); array<int, 3> v = {0, 0, 0}; for (int i : d) { v[0] = i; sort(v.begin(), v.end()); } for (int i = 1; i <= n; i++) pf[i] = pf[i-1] + l[i-1]; //int ll = v[1] + v[2] + c - 1, rr = INF; int ll = 0, rr = INF; while (rr - ll > 1) { int m = ll+rr>>1; if (check(m)) rr = m; else ll = m; } return rr; }

컴파일 시 표준 에러 (stderr) 메시지

shortcut.cpp: In function 'long long int find_shortcut(int32_t, std::vector<int>, std::vector<int>, int32_t)':
shortcut.cpp:69:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   69 |   int m = ll+rr>>1;
      |           ~~^~~
#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...