• 欢迎光临~

NOI Online 2021

开发技术 开发技术 2022-09-23 次浏览

普及 切蛋糕(红)

大力分讨

点击查看代码
#include <bits/stdc++.h>
#define ff fflush(stdout)
#define thank puts("感恩😅😅😅😅"), ff
#define fop(x, l, r) for (register int x = l; x <= r; ++x)
#define fio(x, r, l) for (register int x = r; x >= l; --x)
using namespace std;
typedef long long ll;
void ckmax(int &a, int b) { a = max(a, b); }
void ckmin(int &a, int b) { a = min(a, b); }

int read() {
    int x = 0;
    char c;
    bool f = 0;
    while (!isdigit(c = getchar())) {
        if (c == '-') f = 1;
    }
    do {
        x = (x << 1) + (x << 3) + (c ^ 48);
    } while (isdigit(c = getchar()));
    if (f) return -x;
    return x;
}

const int maxn = 5e2 + 1;

int main() {
    int T = read();
    while (T--) {
        int a = read(), b = read(), c = read();
        if (c < b) swap(b, c);
        if (b < a) swap(a, b);
        if (c < b) swap(b, c);
        if (!a && !b) puts("0");
        else if (!a && b == c) puts("1");
        else if (!a || a + b == c || a == b || b == c) puts("2");
        else puts("3");
    }
}

普及 吃豆人 (黄)

好耶我拿最优解了(雾)

NOI Online 2021

大力模拟特判

点击查看代码
#include <bits/stdc++.h>
#define ff fflush(stdout)
#define thank puts("感恩😅😅😅😅"), ff
#define fop(x, l, r) for (register int x = l; x <= r; ++x)
#define fio(x, r, l) for (register int x = r; x >= l; --x)
using namespace std;
typedef long long ll;
void ckmax(int &a, int b) { a = max(a, b); }
void ckmin(int &a, int b) { a = min(a, b); }

int read() {
    int x = 0;
    char c;
    bool f = 0;
    while (!isdigit(c = getchar())) {
        if (c == '-') f = 1;
    }
    do {
        x = (x << 1) + (x << 3) + (c ^ 48);
    } while (isdigit(c = getchar()));
    if (f) return -x;
    return x;
}

const int maxn = 1e3 + 3;

int a[maxn][maxn];
int val[maxn];
int n;

int rep(int x, int y) {
    if ((y - x) & 1) return 0;
    if (x == 1 && y == n) return a[(n + 1) / 2][(n + 1) / 2];
    if (x == 1) return a[(y + 1) / 2][(y + 1) / 2] + a[(2 * n - y + 1) / 2][(2 * n - y + 1) / 2];
    if (y == n) return a[(n - x) / 2 + 1][(n + x) / 2] + a[(n + x) / 2][(n - x) / 2 + 1];
    return a[(x + y) / 2][(y - x) / 2 + 1] + a[(y - x) / 2 + 1][(x + y) / 2] + a[n - (y - x) / 2][n - (x + y) / 2 + 1] + a[n - (x + y) / 2 + 1][n - (y - x) / 2];
}

int main() {
    n = read();
    fop(i, 1, n) fop(j, 1, n) a[i][j] = read();
    fop(i, 1, n) fop(j, 1, n) {
        int x = i + j <= n ? i + j - 1 : n + n - i - j + 1;
        int y = j >= i ? j - i + 1 : i - j + 1;
        val[x] += a[i][j];
        if (x != y) val[y] += a[i][j];
    }
    int ans = 0;
    fop(i, 1, n) fop(j, i + 1, n) {
        ans = max(ans, val[i] + val[j] - rep(i, j));
    }
    printf("%dn", ans);
}
程序员灯塔
转载请注明原文链接:NOI Online 2021
喜欢 (0)