제출 #24584

#제출 시각아이디문제언어결과실행 시간메모리
24584gs14004Shortcut (IOI16_shortcut)C++11
컴파일 에러
0 ms0 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; typedef long long lint; int n, c; lint a[1000005], b[1000005]; bool trial(lint x){ lint ps = -1e18, pe = 1e18, ms = -1e18, me = 1e18; vector<pi> v, w; for(int i=0; i<n; i++) v.push_back(pi(a[i] + b[i], i)); for(int i=0; i<n; i++) w.push_back(pi(x + -a[i] + b[i], i)); sort(v.begin(), v.end()); sort(w.begin(), w.end()); int p = 0; for(int i=0; i<n; i++){ while(p < n && w[p].first < v[i].first){ mxp = max(mxp, a[w[p].second] + b[w[p].second]); mxm = max(mxm, -a[w[p].second] + b[w[p].second]); mnp = min(mnp, a[w[p].second] + b[w[p].second]); mnm = min(mnm, -a[w[p].second] + b[w[p].second]); } ps = max(ps, mxp - x + c + b[v[i].second] + a[v[i].second]); pe = min(pe, mnm + x - c + b[v[i].second] - a[v[i].second]); ms = max(ms, mxp - x + c - b[v[i].second] + a[v[i].second]); me = min(me, mnm + x - c - b[v[i].second] - a[v[i].second]); } /* for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ if(b[j] + a[j] > x + b[i] - a[i]){ lint r = x - c - a[i] - a[j]; ps = max(ps, b[i] + a[i] - x + c + b[j] + a[j]); pe = min(pe, b[i] - a[i] + x - c + b[j] - a[j]); ms = max(ms, b[i] + a[i] - x + c - b[j] + a[j]); me = min(me, b[i] - a[i] + x - c - b[j] - a[j]); } } }*/ for(int i=0; i<n; i++){ lint s = max(ps - b[i], b[i] - me); lint e = min(pe - b[i], b[i] - ms); if(s <= e && upper_bound(b, b+n, e) != lower_bound(b, b+n, s)) return true; } return false; } long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c) { ::n = n; ::c = c; for(int i=0; i<n; i++){ a[i] = d[i]; if(i >= 1) b[i] = b[i-1] + l[i-1]; } lint s = 0, e = 1e16; while(s != e){ lint m = (s+e)/2; if(trial(m)) e = m; else s = m+1; } return s; }

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

shortcut.cpp: In function 'bool trial(lint)':
shortcut.cpp:10:9: error: 'pi' was not declared in this scope
  vector<pi> v, w;
         ^
shortcut.cpp:10:11: error: template argument 1 is invalid
  vector<pi> v, w;
           ^
shortcut.cpp:10:11: error: template argument 2 is invalid
shortcut.cpp:11:27: error: request for member 'push_back' in 'v', which is of non-class type 'int'
  for(int i=0; i<n; i++) v.push_back(pi(a[i] + b[i], i));
                           ^
shortcut.cpp:12:27: error: request for member 'push_back' in 'w', which is of non-class type 'int'
  for(int i=0; i<n; i++) w.push_back(pi(x + -a[i] + b[i], i));
                           ^
shortcut.cpp:13:9: error: request for member 'begin' in 'v', which is of non-class type 'int'
  sort(v.begin(), v.end());
         ^
shortcut.cpp:13:20: error: request for member 'end' in 'v', which is of non-class type 'int'
  sort(v.begin(), v.end());
                    ^
shortcut.cpp:14:9: error: request for member 'begin' in 'w', which is of non-class type 'int'
  sort(w.begin(), w.end());
         ^
shortcut.cpp:14:20: error: request for member 'end' in 'w', which is of non-class type 'int'
  sort(w.begin(), w.end());
                    ^
shortcut.cpp:17:21: error: invalid types 'int[int]' for array subscript
   while(p < n && w[p].first < v[i].first){
                     ^
shortcut.cpp:17:34: error: invalid types 'int[int]' for array subscript
   while(p < n && w[p].first < v[i].first){
                                  ^
shortcut.cpp:18:4: error: 'mxp' was not declared in this scope
    mxp = max(mxp, a[w[p].second] + b[w[p].second]);
    ^
shortcut.cpp:18:24: error: invalid types 'int[int]' for array subscript
    mxp = max(mxp, a[w[p].second] + b[w[p].second]);
                        ^
shortcut.cpp:18:41: error: invalid types 'int[int]' for array subscript
    mxp = max(mxp, a[w[p].second] + b[w[p].second]);
                                         ^
shortcut.cpp:19:4: error: 'mxm' was not declared in this scope
    mxm = max(mxm, -a[w[p].second] + b[w[p].second]);
    ^
shortcut.cpp:19:25: error: invalid types 'int[int]' for array subscript
    mxm = max(mxm, -a[w[p].second] + b[w[p].second]);
                         ^
shortcut.cpp:19:42: error: invalid types 'int[int]' for array subscript
    mxm = max(mxm, -a[w[p].second] + b[w[p].second]);
                                          ^
shortcut.cpp:20:4: error: 'mnp' was not declared in this scope
    mnp = min(mnp, a[w[p].second] + b[w[p].second]);
    ^
shortcut.cpp:20:24: error: invalid types 'int[int]' for array subscript
    mnp = min(mnp, a[w[p].second] + b[w[p].second]);
                        ^
shortcut.cpp:20:41: error: invalid types 'int[int]' for array subscript
    mnp = min(mnp, a[w[p].second] + b[w[p].second]);
                                         ^
shortcut.cpp:21:4: error: 'mnm' was not declared in this scope
    mnm = min(mnm, -a[w[p].second] + b[w[p].second]);
    ^
shortcut.cpp:21:25: error: invalid types 'int[int]' for array subscript
    mnm = min(mnm, -a[w[p].second] + b[w[p].second]);
                         ^
shortcut.cpp:21:42: error: invalid types 'int[int]' for array subscript
    mnm = min(mnm, -a[w[p].second] + b[w[p].second]);
                                          ^
shortcut.cpp:23:16: error: 'mxp' was not declared in this scope
   ps = max(ps, mxp - x + c + b[v[i].second] + a[v[i].second]);
                ^
shortcut.cpp:23:35: error: invalid types 'int[int]' for array subscript
   ps = max(ps, mxp - x + c + b[v[i].second] + a[v[i].second]);
                                   ^
shortcut.cpp:23:52: error: invalid types 'int[int]' for array subscript
   ps = max(ps, mxp - x + c + b[v[i].second] + a[v[i].second]);
                                                    ^
shortcut.cpp:24:16: error: 'mnm' was not declared in this scope
   pe = min(pe, mnm + x - c + b[v[i].second] - a[v[i].second]);
                ^
shortcut.cpp:24:35: error: invalid types 'int[int]' for array subscript
   pe = min(pe, mnm + x - c + b[v[i].second] - a[v[i].second]);
                                   ^
shortcut.cpp:24:52: error: invalid types 'int[int]' for array subscript
   pe = min(pe, mnm + x - c + b[v[i].second] - a[v[i].second]);
                                                    ^
shortcut.cpp:25:35: error: invalid types 'int[int]' for array subscript
   ms = max(ms, mxp - x + c - b[v[i].second] + a[v[i].second]);
                                   ^
shortcut.cpp:25:52: error: invalid types 'int[int]' for array subscript
   ms = max(ms, mxp - x + c - b[v[i].second] + a[v[i].second]);
                                                    ^
shortcut.cpp:26:35: error: invalid types 'int[int]' for array subscript
   me = min(me, mnm + x - c - b[v[i].second] - a[v[i].second]);
                                   ^
shortcut.cpp:26:52: error: invalid types 'int[int]' for array subscript
   me = min(me, mnm + x - c - b[v[i].second] - a[v[i].second]);
                                                    ^