#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cctype>
#define R register
#define N 100005
#define uint unsigned int
uint n, seed, t[N], tot;
inline uint uint_rand() {
seed ^= seed << 11, seed ^= seed >> 7, seed ^= seed << 21;
return seed;
}
inline uint uint_out() {
uint res = n, x = uint_rand();
for (uint i = 1; i <= tot; ++i) res ^= t[i] + x, x = uint_rand();
return res;
}
inline uint search(uint x) {
R uint l = 1, r = tot;
while (l < r) {
uint mid = l + r >> 1;
t[mid] <= x ? l = mid + 1 : r = mid;
}
return l;
}
int main() {
scanf("%u %u", &n, &seed);
for (R uint i = 1; i <= n; ++i) {
R uint x = uint_rand();
x >= t[tot] ? t[++tot] = x : t[search(x)] = x;
}
printf("%u\n%u", tot, uint_out());
return 0;
}
算法标签:贪心 + 二分查找。
时间复杂度: O ( n log n ) O(n\log n) O(nlogn)。
提交记录:T123482 最长不下降子序列