Description:
For a 16-binary sequence, a subsequence is selected, and each item of the subsequence is given a different or lower-order in the sub-sequence.
Solution:
The maximum number of 255 is found, then only 8 digits are considered. DP[I][J] indicates that the number of I must be selected, and the current subscript 8 bits is the largest and the J. Since the next eight bits are determined, we naturally want the current subscript to be as large as possible. The maximum subscript can be obtained and then transferred.
#include <cstdio> #include <cstring> #include <algorithm> using namespace
Std
const int bit = 256;
int n;
Long long ans;
Long Long dp[100005][bit], a[100005], mx[bit];
int main () {scanf ("%d", &n);
for (int i = 0; i < n; ++i) {scanf ("%x", &a[i]);
} for (int i = 0, i < n; ++i) {for (int j = 0; j < bit; ++j) {int k = i/bit * bit + j;
if (k > i) {k-= bit;
} if (K < 0) {continue;
} Dp[i][j] = mx[((j-1)% bit + bit)% bit] + (A[i] ^ k);
} for (int j = 0; j < bit; ++j) {Mx[j] = max (Mx[j], dp[i][j]);
}} for (int i = 0; i < bit; ++i) {ans = max (ans, mx[i]);
} printf ("%lld\n", ans);
return 0; }