제출 #342172

#제출 시각아이디문제언어결과실행 시간메모리
342172ezdp수열 (APIO14_sequence)C++17
컴파일 에러
0 ms0 KiB
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #define endl '\n' #define pb push_back #define fr first #define sc second #define ll long long int #define ld long double #define bit(idx) idx&(-idx) #define bin(x) bitset<32>(x) #define all(A) A.begin(), A.end() #define de(x) cout << #x << " = " << x << endl; #define row vector<ll> #define row_matrix vector<ll> #define matrix vector<row_matrix> #define ordered_set_T int using namespace std; using namespace __gnu_pbds; typedef tree<ordered_set_T, null_type, less<ordered_set_T>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; /// find_by_order(x) -> x-th element in the set /// order_of_key(x) -> how many elements are smaller than x /// insert(x) -> inserts x into the set const ll MAXN = 1e6 + 5; const ll MAXK = 256; ll n, k, prefix[MAXN], A[MAXN], dp[MAXK][MAXN], opt[MAXK][MAXN]; ll f(ll l, ll r){ return (l == 0 ? 0 : prefix[l - 1]) * (prefix[r] - (l == 0 ? 0 : prefix[l - 1])); } void solve(ll i, ll l, ll r, ll tl, ll tr){ if(l > r){ return; } ll m = (l + r) / 2; for(ll _t = max(tl, i - 1); _t <= min(tr, m); _t ++){ if(dp[i - 1][_t - 1] + f(_t, m) > dp[i][m]){ opt[i][m] = _t; dp[i][m] = dp[i - 1][_t - 1] + f(_t, m); } } solve(i, l, m - 1, tl, opt[i][m]); solve(i, m + 1, r, opt[i][m], tr); } int main(){ /// ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; for(int i = 0; i < n; i ++) cin >> A[i]; prefix[0] = A[0]; for(int i = 1; i < n; i ++) prefix[i] = prefix[i - 1] + A[i]; for(int _k = 2; _k <= k + 1; _k ++){ solve(_k, 0, n - 1, 0, n - 1); } cout << dp[k + 1][n - 1] << endl; row v; ll tmp = opt[k + 1][n - 1], r = k; while(tmp){ v.pb(tmp); tmp = opt[r --][tmp - 1]; } reverse(all(v)); for(auto x : v) cout << x << " "; cout << endl; } /** */

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

sequence.cpp: In function 'int main()':
sequence.cpp:70:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   70 |  for(auto x : v) cout << x << " "; cout << endl;
      |  ^~~
sequence.cpp:70:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   70 |  for(auto x : v) cout << x << " "; cout << endl;
      |                                    ^~~~
/tmp/cc8kNobT.o: In function `f(long long, long long)':
sequence.cpp:(.text+0x3): relocation truncated to fit: R_X86_64_PC32 against symbol `prefix' defined in .bss section in /tmp/cc8kNobT.o
/tmp/cc8kNobT.o: In function `solve(long long, long long, long long, long long, long long)':
sequence.cpp:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `prefix' defined in .bss section in /tmp/cc8kNobT.o
sequence.cpp:(.text+0xb2): relocation truncated to fit: R_X86_64_PC32 against symbol `prefix' defined in .bss section in /tmp/cc8kNobT.o
/tmp/cc8kNobT.o: In function `main':
sequence.cpp:(.text.startup+0x5): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8kNobT.o
sequence.cpp:(.text.startup+0xc): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(globals_io.o)
sequence.cpp:(.text.startup+0x32): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc8kNobT.o
sequence.cpp:(.text.startup+0x41): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8kNobT.o
sequence.cpp:(.text.startup+0x51): relocation truncated to fit: R_X86_64_PC32 against symbol `A' defined in .bss section in /tmp/cc8kNobT.o
sequence.cpp:(.text.startup+0x5a): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(globals_io.o)
sequence.cpp:(.text.startup+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8kNobT.o
sequence.cpp:(.text.startup+0x8d): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status