BZOJ1040 [ZJOI2008]骑士
<div class="post_brief"><p> 多少年前的坑了。</p> 用mac写的第一篇题解呢。 环套树DP。先把树上的情况处理了,然后枚举取不取环上的第一个。 要注意会有重边的情况,比较恶心。 #include <cstdio> #include <cctype> #include <cstring> #include <algorithm> using namespace std; const int buf_len = 4000; char buf[buf_len], *bufb(buf), *bufe(buf + 1); #define readBuf() { if (++ bufb == bufe) bufe = (bufb = buf) + fread(buf, 1, sizeof(buf), stdin); } #define readInt(x) { register int s(0); do { readBuf(); } while (!isdigit(*bufb)); do { s = s * 10 + *bufb - 48; readBuf(); } while (isdigit(*bufb)); x = s; }...