Educational Codeforces Round 48 (Rated for Div. 2) - 赛后补题
Posted zgglj-com
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 48 (Rated for Div. 2) - 赛后补题相关的知识,希望对你有一定的参考价值。
题解:拿笔画他的行走路线,你会发现可以前缀和预处理一些东西出来。
const int N = 300005; int n; ll a[N], b[N], dp[2][N], sp[2][N], sum[N]; int get_a() { dp[0][0] = 0; for (int i = 1; i < n; ++i) { dp[0][i] = dp[0][i - 1] + 1ll * i * a[i]; } int t = n; dp[1][n - 1] = dp[0][n - 1] + 1ll * t * b[n - 1]; for (int i = n - 2; ~i; --i) { t++; dp[1][i] = dp[1][i + 1] + 1ll * t * b[i]; } } int get_b() { sp[1][0] = b[1]; for (int i = 1; i < n; ++i) sp[1][i] = sp[1][i - 1] + 1ll * (i + 1) * b[i]; int t = n + 1; sp[0][n - 1] = sp[1][n - 1] + 1ll * t * a[n - 1]; for (int i = n - 2; ~i; --i) { t++; sp[0][i] = sp[0][i + 1] + 1ll * t * a[i]; } } void Inite() { for (int i = n - 1; ~i; --i) sum[i] = sum[i + 1] + a[i] + b[i]; } void solve() { ll ans = max(dp[1][0], sp[0][1]); int last = 0; ll tp = 0; for (int i = 0; i < n; ++i) { if(!last) { tp += 1ll * 2 * i * a[i] + 1ll * (2 * i + 1) * b[i]; if(i + 1 != n) ans = max(ans, tp + 1ll * i * sum[i + 1] + sp[0][i + 1] - sp[1][i]); } else { tp += 1ll * 2 * i * b[i] + 1ll * (2 * i + 1) * a[i]; if(i + 1 != n) ans = max(ans, tp + 1ll * (i + 1) * sum[i + 1] + dp[1][i + 1] - dp[0][i]); } last ^= 1; } printf("%I64d ", max(ans, tp)); }
题解:可以这么构造,除了第一行,第一列填上以外,其它的行和列都填0,所以主要是算map[1][1]改填几,或者填最后一行和最后一列。
ans[n][m] = b[m] ^ (x ^ a[n]);
以上是关于Educational Codeforces Round 48 (Rated for Div. 2) - 赛后补题的主要内容,如果未能解决你的问题,请参考以下文章
Educational Codeforces Round 7 A
Educational Codeforces Round 7
Educational Codeforces Round 90
Educational Codeforces Round 33