Logo Wy Online Judge

WyOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#475#94. 「NOIP2021」报数PigsyyCompile Error//C++232.2kb2025-04-24 20:52:192025-04-24 20:52:19

answer

#define P(A) A=-~A
#define fione(i,a,b) for(register int i=a;i<=b;P(i))
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cctype>
typedef long long LL;
typedef unsigned long long ULL;
namespace FastIo {
typedef __uint128_t ULLL;
static char buf[100000], *p1 = buf, *p2 = buf, fw[100000], *pw = fw;
#define gc p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++
inline void pc(const char &ch) {
    if (pw - fw == 100000)
        fwrite(fw, 1, 100000, stdout), pw = fw;

    *pw++ = ch;
}
#define fsh fwrite(fw,1,pw-fw,stdout),pw=fw
struct FastMod {
    FastMod(ULL b): b(b), m(ULL((ULLL(1) << 64) / b)) {}
    ULL reduce(ULL a) {
        ULL q = (ULL)((ULLL(m) * a) >> 64);
        ULL r = a - q * b;
        return r >= b ? r - b : r;
    }
    ULL b, m;
} HPOP(10);
struct QIO {
    char ch;
    int st[40];
    bool pd;
    template<class T>inline void read(T &x) {
        x = 0, ch = gc, pd = false;

        while (!isdigit(ch)) {
            pd = ch == '-' ? true : false;
            ch = gc;
        }

        while (isdigit(ch)) {
            x = (x << 3) + (x << 1) + (ch ^ 48);
            ch = gc;
        }

        if (pd)
            x = -x;
    }
    template<class T>inline void write(T a) {
        if (a < 0)
            a = -a, pc('-');

        do {
            st[++st[0]] = HPOP.reduce(a);
            a /= 10;
        } while (a);

        while (st[0])
            pc(st[st[0]--] ^ 48);
    }
} qrw;
}
using namespace FastIo;
const int NUMBER1 = 1e6;
struct NODE {
    int l, r;
    LL v;
} tr[NUMBER1 + 5];
bool check(int l, int r) {
    if (!(~l) && !(~r))
        return true;

    if (!(~l) || !(~r) || tr[l].v != tr[r].v)
        return false;

    return check(tr[l].l, tr[r].r) && check(tr[l].r, tr[r].l);
}
LL sum(int u) {
    return ~u ? sum(tr[u].l) + sum(tr[u].r) + 1 : 0;
}
signed main() {
    int n;
    LL ans(0);
    qrw.read(n);
    fione(i, 1, n)qrw.read(tr[i].v);
    fione(i, 1, n) {
        qrw.read(tr[i].l);
        qrw.read(tr[i].r);
    }

    fione(i, 1, n)if (check(i, i))
        ans = std::max(ans, sum(i));

    qrw.write(ans);
    fsh;
    exit(0);
    return 0;
}

详细

answer.code:11:9: error: ‘__uint128_t’ does not name a type; did you mean ‘__uint8_t’?
   11 | typedef __uint128_t ULLL;
      |         ^~~~~~~~~~~
      |         __uint8_t
answer.code: In constructor ‘FastIo::FastMod::FastMod(ULL)’:
answer.code:22:34: error: ‘ULLL’ was not declared in this scope; did you mean ‘ULL’?
   22 |     FastMod(ULL b): b(b), m(ULL((ULLL(1) << 64) / b)) {}
      |                                  ^~~~
      |                                  ULL
answer.code: In member ...