全部评论 2

  • 这不AI吗

    2天前 来自 浙江

    0
  • #include <bits/stdc++.h>
    using namespace std;
    
    using uint = unsigned int;
    using ll = long long;
    static const int MOD = 1000000007;
    static const int MAXN = 5005;
    
    // ---------- fast fread/fwrite I/O ----------
    static const int BUFSIZE = 1 << 20;
    static char ibuf[BUFSIZE];
    static int ipos = 0, ilen = 0;
    static inline char nextChar() {
        if (ipos >= ilen) {
            ilen = (int)fread(ibuf, 1, BUFSIZE, stdin);
            ipos = 0;
            if (ilen == 0) return EOF;
        }
        return ibuf[ipos++];
    }
    static inline void readInt(int &out) {
        char c; int sign = 1; int x = 0;
        do { c = nextChar(); if (c == EOF) { out = 0; return; } } while (c <= ' ');
        if (c == '-') { sign = -1; c = nextChar(); }
        for (; c > ' '; c = nextChar()) x = x * 10 + (c - '0');
        out = x * sign;
    }
    
    static char obuf[BUFSIZE];
    static int opos = 0;
    static inline void flushOut() {
        if (opos) {
            fwrite(obuf, 1, opos, stdout);
            opos = 0;
        }
    }
    static inline void writeChar(char c) {
        if (opos >= BUFSIZE) flushOut();
        obuf[opos++] = c;
    }
    static inline void writeIntLn(int x) {
        if (x == 0) {
            writeChar('0'); writeChar('\n'); return;
        }
        if (x < 0) { writeChar('-'); x = -x; }
        char s[16]; int n = 0;
        while (x) { s[n++] = char('0' + (x % 10)); x /= 10; }
        while (n--) writeChar(s[n]);
        writeChar('\n');
    }
    // ---------- end IO ----------
    
    // Global arrays (to avoid dynamic alloc overhead)
    static int a[MAXN];
    static int q0[MAXN], q1[MAXN]; // indices (1-based original index)
    static int cnt0, cnt1;
    static int posInParity[MAXN];  // posInParity[orig_index] -> 0-based rank inside its parity group
    static int preArr[MAXN];       // pre per original index
    
    // dp rolling arrays
    static int dp[MAXN], nxt[MAXN];
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int T;
        readInt(T);
        while (T--) {
            int n;
            readInt(n);
            // read array (1-based index used for convenience)
            for (int i = 1; i <= n; +
    

    4天前 来自 江西

    0
暂无数据

提交答案之后,这里将显示提交结果~

首页