1. 程式人生 > >Educational Codeforces Round 48 (Rated for Div. 2) - 賽後補題

Educational Codeforces Round 48 (Rated for Div. 2) - 賽後補題

tro const nbsp [1] blank printf and for contest

C. Vasya And The Mushrooms

題解:拿筆畫他的行走路線,你會發現可以前綴和預處理一些東西出來。

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\n", max(ans, tp)); }

D. Vasya And The Matrix

題解:可以這麽構造,除了第一行,第一列填上以外,其它的行和列都填0,所以主要是算map[1][1]改填幾,或者填最後一行和最後一列。

 ans[n][m] = b[m] ^ (x ^ a[n]);

Educational Codeforces Round 48 (Rated for Div. 2) - 賽後補題