제출 #461249

#제출 시각아이디문제언어결과실행 시간메모리
461249hhhhaura수열 (APIO14_sequence)C++14
컴파일 에러
0 ms0 KiB
#define wiwihorz #pragma GCC optimize("Ofast") #pragma loop-opt(on) #include <bits/stdc++.h> #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define all(x) x.begin(), x.end() #define ceil(a, b) ((a + b - 1) / (b)) #define INF 1000000000000000000 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define lld long double #define int long long int #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) cerr << "Line " << __LINE__ <<": ", kout("[" + string(#a) + "] = ", a) void kout() {cerr << endl;} void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;} template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); } #else #define print(...) 0 #define vprint(...) 0 #endif #define a first #define b second namespace solver { int n, k; vector<int> dp[2], pre, a, pos; vector<vector<int>> rec; int get_val(pii p, int x) { return p.a * x + p.b; } bool check(pii i, pii j, pii k) { return (i.a - j.a) * (k.b - i.b) < (j.b - i.b) * (i.a - k.a); } void init_(int _n, int _k) { n = _n, k = _k; dp[0].assign(n + 1, 0); dp[1].assign(n + 1, 0); pre.assign(n + 1, 0); a.assign(n + 1, 0); rec.assign(k + 2, vector<signed>(n + 1, 0)); } void solve() { vector<pii> q(n + 1, {0, 0}); pos.assign(n + 1, 0); rep(i, 1, n) pre[i] = pre[i - 1] + a[i]; rep(l, 1, k + 1) { int id = l & 1, L = 1, R = 1; q[1] = {-pre[l - 1], dp[!id][l - 1]}; pos[1] = l - 1; rep(i, l, n) { int suf = pre[n] - pre[i]; while(L < R && get_val(q[L], suf) <= get_val(q[L + 1], suf)) L ++; dp[id][i] = get_val(q[L], suf) + pre[i] * suf; rec[l][i] = pos[L]; pii cur = {-pre[i], dp[!id][i]}; while(R > L && !check(q[R - 1], q[R], cur)) R--; q[++R] = cur, pos[R] = i; } } cout << dp[(k + 1) & 1][n] << "\n"; vector<int> ans(k + 1, 0); int cur = n; rrep(i, 1, k) { ans[i] = rec[i + 1][cur]; cur = rec[i + 1][cur]; } rep(i, 1, k) cout << ans[i] << " \n"[i == k]; } }; using namespace solver; signed main() { ios::sync_with_stdio(false), cin.tie(0); int n, k; cin >> n >> k; init_(n, k); rep(i, 1, n) cin >> a[i]; solve(); return 0; }

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

sequence.cpp:3: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    3 | #pragma loop-opt(on)
      | 
sequence.cpp:25:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   25 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
sequence.cpp:25:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   25 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
sequence.cpp: In function 'void solver::init_(long long int, long long int)':
sequence.cpp:50:45: error: no matching function for call to 'std::vector<std::vector<long long int> >::assign(long long int, std::vector<int>)'
   50 |   rec.assign(k + 2, vector<signed>(n + 1, 0));
      |                                             ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from sequence.cpp:4:
/usr/include/c++/10/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:749:47: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const value_type&' {aka 'const std::vector<long long int>&'}
  749 |       assign(size_type __n, const value_type& __val)
      |                             ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  768 |  assign(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note:   template argument deduction/substitution failed:
sequence.cpp:50:45: note:   deduced conflicting types for parameter '_InputIterator' ('long long int' and 'std::vector<int>')
   50 |   rec.assign(k + 2, vector<signed>(n + 1, 0));
      |                                             ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from sequence.cpp:4:
/usr/include/c++/10/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:794:7: note:   candidate expects 1 argument, 2 provided