关于程序变量名
查看原帖
关于程序变量名
1088732
GXZJQ楼主2024/10/27 09:12

RT

我在储存车的时候用了 c 数组,但快读里面又定义了一个 c 字符,这样会有事吗。

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int T;
int n, m, L, V, Special_0;
struct Car {
    int d, v, a;
} c[N];
int p[N];
bool Special_A = 1, Special_B = 1, Special_C = 1;

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x *= 10;
        x += (c - '0');
        c = getchar();
    }
    return x * f;
}

void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

void DFS(string now, string cnt) {
    if (now.length() == m) {
        int res = 0;
        for (int i = 0; i < m; i++) if (now[i] == '0') res++;
        bool eup_limit[21];
        for (int i = 1; i <= 20; i++) eup_limit[i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (now[j - 1] == '0') continue;
                if (p[j] < c[i].d) continue;
                long long UP = V * V;
                long long kkk = c[i].v * c[i].v + 2 * c[i].a * (p[j] - c[i].d);
                if (kkk <= 0) break;
                if (kkk > UP) if (eup_limit[i] == 0) eup_limit[i] = 1;
            }
        }
        string tmp = "";
        for (int i = 1; i <= n; i++) if (eup_limit[i] == 1) tmp += '1'; else tmp += '0';
        // cout << tmp << endl;
        if (tmp == cnt) Special_0 = max(Special_0, res);
        return;
    } else {
        DFS(now + '0', cnt);
        DFS(now + '1', cnt);
    }
}

int main() {
    // freopen("detect4.in", "r", stdin);
    // freopen("detect4.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    T = read();
    while (T--) {
        Special_A = 1, Special_B = 1, Special_C = 1;
        n = read(), m = read(), L = read(), V = read();
        for (int i = 1; i <= n; i++) {
            c[i].d = read(), c[i].v = read(), c[i].a = read();
            if (c[i].a != 0) Special_A = 0;
            if (c[i].a <= 0) Special_B = 0;
            if (c[i].a >= 0) Special_C = 0;
        }
        for (int i = 1; i <= m; i++) p[i] = read();
        if (n <= 20 && m <= 20) {
            int ans1 = 0;
            bool up_limit[21];
            for (int i = 1; i <= 20; i++) up_limit[i] = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (p[j] < c[i].d) continue;
                    long long UP = V * V;
                    long long now = c[i].v * c[i].v + 2 * c[i].a * (p[j] - c[i].d);
                    if (now <= 0) break;
                    if (now > UP) {
                        if (up_limit[i] == 0) {
                            up_limit[i] = 1;
                            // cout << i << " ";
                            ans1++;
                            break;
                        }
                    }
                }
            }
            // cout << endl;
            write(ans1), putchar(' ');
            if (ans1 == 0) write(m), puts("");
            else {
                string s = "";
                for (int i = 1; i <= n; i++) if (up_limit[i] == 1) s += '1'; else s += '0';
                Special_0 = 0;
                DFS("", s);
                write(Special_0), puts("");
                continue;
            }
        }
        if (Special_A == 1) {
            int ans1 = 0;
            for (int i = 1; i <= n; i++) {
                if (c[i].d > p[m]) continue;
                if (c[i].v > V) ans1++;
            }
            write(ans1), putchar(' ');
            if (ans1 == 0) write(m), puts("");
            else write(m - 1), puts("");
            continue;
        }
        if (Special_B == 1) {
            long long UP = V * V;
            int ans1 = 0;
            for (int i = 1; i <= n; i++) {
                if (c[i].d > p[m]) continue;
                long long now = c[i].v * c[i].v + 2 * c[i].a * (p[m] - c[i].d);
                if (now > UP) ans1++;
            }
            write(ans1), putchar(' ');
            if (ans1 == 0) write(m), puts("");
            else write(m - 1), puts("");
            continue;
        }
    }
    return 0;
}

在 NOI Linux 下可以过编译,Dev 啥警告都没有

2024/10/27 09:12
加载中...