제출 #1198226

#제출 시각아이디문제언어결과실행 시간메모리
1198226InvMOD코알라 (JOI13_koala)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define eb emplace_back #define vi vector<int> #define pi pair<int,int> #define sz(v) (int)(v).size() #define all(v) (v).begin(), (v).end() #define compact(v) (v).erase(unique(all(v)), (v).end()) template<class T> using upq = priority_queue<T, vector<T>, greater<T>>; template<class T> int lwrbound(const vector<T>& a, const T& b, const int s = 0){return int(lower_bound(s + all(a), b) - a.begin());} template<class T> int uprbound(const vector<T>& a, const T& b, const int s = 0){return int(upper_bound(s + all(a), b) - a.begin());} #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define ROF(i, a, b) for(int i = (a); i >= (b); i--) #define sumof(x) accumulate(all(x), 0ll) #define dbg(x) "[" << #x " = " << (x) << "]" #define el "\n" using ll = long long; using ld = long double; template<class T> bool ckmx(T& a, const T b){return (a < b ? a = b, true : false);} template<class T> bool ckmn(T& a, const T b){return (a > b ? a = b, true : false);} const int N = 1e5 + 5; const ll INF = 1e18; struct BIT{ vector<ll> bit; BIT(int n = 0): bit(n + 1, -INF) {} void updPre(int p, ll val){ for(; p < sz(bit); p += p & -p){ ckmx(bit[p], val); } } ll queryPre(int p){ ll ans = 0; for(; p > 0; p -= p & -p){ ckmx(ans, bit[p]); } return ans; } void updSuf(int p, ll val){ for(; p > 0; p -= p & -p){ ckmx(bit[p], val); } } ll querySuf(int p){ ll ans = -INF; for(; p < sz(bit); p += p & -p){ ckmx(ans, bit[p]); } return ans; } }; int n, m, k, d, reduce, cord[N], heal[N]; ll dp[N]; vector<int> comp; void Main() { cin >> k >> m >> d >> reduce >> n; cord[0] = k, heal[0] = 0; FOR(i, 1, n){ cin >> cord[i] >> heal[i]; } cord[n + 1] = m, heal[n + 1] = 0; /* Brute: FOR(i, 1, n + 1){ dp[i] = -INF; FOR(j, 0, i - 1){ ckmx(dp[i], dp[j] - 1ll * (cord[i] - cord[j] + d - 1) / d * reduce + heal[i]); } } cout << dp[n + 1] << el; */ /* dp[j] + 1ll * (cord[j] / d) * reduce + heal[i] - (cord[i] / d) * reduce - (cord[i] % d > cord[j] % d ? reduce : 0) */ FOR(i, 0, n + 1) comp.eb(cord[i] % d); comp.eb(-1); sort(all(comp)), compact(comp); BIT pre(sz(comp)), suf(sz(comp)); FOR(i, 0, n + 1){ int p = lwrbound(comp, cord[i] % d); if(i){ dp[i] = -INF; ckmx(dp[i], 1ll * heal[i] - 1ll * (cord[i] / d) * reduce + suf.querySuf(p)); ckmx(dp[i], 1ll * heal[i] - 1ll * (cord[i] / d + 1) * reduce + pre.queryPre(p)); } pre.updPre(p, dp[i] + 1ll * (cord[i] / d) * reduce); suf.updSuf(p, dp[i] + 1ll * (cord[i] / d) * reduce); } cout << dp[n + 1] << el; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "InvMOD" if(fopen(name".INP", "r")){ freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); } int t = 1; while(t--) Main(); return 0; }

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

koala.cpp: In function 'void Main()':
koala.cpp:76:27: error: reference to 'reduce' is ambiguous
   76 |     cin >> k >> m >> d >> reduce >> n;
      |                           ^~~~~~
In file included from /usr/include/c++/11/numeric:741,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/pstl/glue_numeric_defs.h:31:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::value_type> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
   31 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:26:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp)'
   26 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:21:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation)'
   21 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init,
      | ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/numeric:344:5: note:                 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::value_type std::reduce(_InputIterator, _InputIterator)'
  344 |     reduce(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~
/usr/include/c++/11/numeric:327:5: note:                 'template<class _InputIterator, class _Tp> _Tp std::reduce(_InputIterator, _InputIterator, _Tp)'
  327 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~
/usr/include/c++/11/numeric:289:5: note:                 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::reduce(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  289 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~
koala.cpp:70:17: note:                 'int reduce'
   70 | int n, m, k, d, reduce, cord[N], heal[N]; ll dp[N];
      |                 ^~~~~~
koala.cpp:110:63: error: reference to 'reduce' is ambiguous
  110 |             ckmx(dp[i], 1ll * heal[i] - 1ll * (cord[i] / d) * reduce + suf.querySuf(p));
      |                                                               ^~~~~~
In file included from /usr/include/c++/11/numeric:741,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/pstl/glue_numeric_defs.h:31:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::value_type> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
   31 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:26:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp)'
   26 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:21:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation)'
   21 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init,
      | ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/numeric:344:5: note:                 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::value_type std::reduce(_InputIterator, _InputIterator)'
  344 |     reduce(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~
/usr/include/c++/11/numeric:327:5: note:                 'template<class _InputIterator, class _Tp> _Tp std::reduce(_InputIterator, _InputIterator, _Tp)'
  327 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~
/usr/include/c++/11/numeric:289:5: note:                 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::reduce(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  289 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~
koala.cpp:70:17: note:                 'int reduce'
   70 | int n, m, k, d, reduce, cord[N], heal[N]; ll dp[N];
      |                 ^~~~~~
koala.cpp:111:67: error: reference to 'reduce' is ambiguous
  111 |             ckmx(dp[i], 1ll * heal[i] - 1ll * (cord[i] / d + 1) * reduce + pre.queryPre(p));
      |                                                                   ^~~~~~
In file included from /usr/include/c++/11/numeric:741,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/pstl/glue_numeric_defs.h:31:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::value_type> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
   31 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:26:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp)'
   26 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:21:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation)'
   21 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init,
      | ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/numeric:344:5: note:                 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::value_type std::reduce(_InputIterator, _InputIterator)'
  344 |     reduce(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~
/usr/include/c++/11/numeric:327:5: note:                 'template<class _InputIterator, class _Tp> _Tp std::reduce(_InputIterator, _InputIterator, _Tp)'
  327 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~
/usr/include/c++/11/numeric:289:5: note:                 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::reduce(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  289 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~
koala.cpp:70:17: note:                 'int reduce'
   70 | int n, m, k, d, reduce, cord[N], heal[N]; ll dp[N];
      |                 ^~~~~~
koala.cpp:114:53: error: reference to 'reduce' is ambiguous
  114 |         pre.updPre(p, dp[i] + 1ll * (cord[i] / d) * reduce);
      |                                                     ^~~~~~
In file included from /usr/include/c++/11/numeric:741,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/pstl/glue_numeric_defs.h:31:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::value_type> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
   31 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:26:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp)'
   26 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:21:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation)'
   21 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init,
      | ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/numeric:344:5: note:                 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::value_type std::reduce(_InputIterator, _InputIterator)'
  344 |     reduce(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~
/usr/include/c++/11/numeric:327:5: note:                 'template<class _InputIterator, class _Tp> _Tp std::reduce(_InputIterator, _InputIterator, _Tp)'
  327 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~
/usr/include/c++/11/numeric:289:5: note:                 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::reduce(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  289 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~
koala.cpp:70:17: note:                 'int reduce'
   70 | int n, m, k, d, reduce, cord[N], heal[N]; ll dp[N];
      |                 ^~~~~~
koala.cpp:115:53: error: reference to 'reduce' is ambiguous
  115 |         suf.updSuf(p, dp[i] + 1ll * (cord[i] / d) * reduce);
      |                                                     ^~~~~~
In file included from /usr/include/c++/11/numeric:741,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/pstl/glue_numeric_defs.h:31:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::value_type> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
   31 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:26:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp)'
   26 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init);
      | ^~~~~~
/usr/include/c++/11/pstl/glue_numeric_defs.h:21:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation)'
   21 | reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Tp __init,
      | ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:84,
                 from koala.cpp:1:
/usr/include/c++/11/numeric:344:5: note:                 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::value_type std::reduce(_InputIterator, _InputIterator)'
  344 |     reduce(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~
/usr/include/c++/11/numeric:327:5: note:                 'template<class _InputIterator, class _Tp> _Tp std::reduce(_InputIterator, _InputIterator, _Tp)'
  327 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~
/usr/include/c++/11/numeric:289:5: note:                 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::reduce(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  289 |     reduce(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~
koala.cpp:70:17: note:                 'int reduce'
   70 | int n, m, k, d, reduce, cord[N], heal[N]; ll dp[N];
      |                 ^~~~~~
koala.cpp: In function 'int32_t main()':
koala.cpp:128:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  128 |         freopen(name".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:129:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  129 |         freopen(name".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~