码迷,mamicode.com
首页 > 其他好文 > 详细

LuoguP2575 高手过招(博弈论)

时间:2019-10-20 21:42:27      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:time   define   int   string   swa   type   str   reg   using   

空格数变吗?不变呀
阶梯博弈阶梯数变吗?不变呀
那这不就阶梯博弈,每行一栋楼,爬完\(mex\)就可以了吗?

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define R(a,b,c) for(register int a = (b); a <= (c); ++a)
#define nR(a,b,c) for(register int a = (b); a >= (c); --a)
#define Fill(a,b) memset(a, b, sizeof(a))
#define Swap(a,b) ((a) ^= (b) ^= (a) ^= (b))

#define ON_DEBUGG

#ifdef ON_DEBUGG

#define D_e_Line printf("-----------\n")
#define D_e(x) std::cout << (#x) << " : " <<x << "\n"
#define FileOpen() freopen("in.txt", "r", stdin)
#define FileSave() freopen("out.txt", "w", stdout)
#define Pause() system("pause")
#include <ctime>
#define TIME() fprintf(stderr, "\nTIME : %.3lfms\n", clock() * 1000.0 / CLOCKS_PER_SEC)

#else

#define D_e_Line ;
#define D_e(x) ;
#define FileOpen() ;
#define FilSave ;
#define Pause() ;
#define TIME() ;

#endif

struct ios {
    template<typename ATP> ios& operator >> (ATP &x) {
        x = 0; int f = 1; char c;
        for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
        while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
        x *= f;
        return *this;
    }
}io;

using namespace std;

template<typename ATP> inline ATP Min(ATP a, ATP b) {
    return a < b ? a : b;
}
template<typename ATP> inline ATP Max(ATP a, ATP b) {
    return a > b ? a : b;
}
template<typename ATP> inline ATP Abs(ATP a) {
    return a < 0 ? -a : a;
}
const int N = 100007;
bool mex[N];
int main() {
    int Tasks;
    io >> Tasks;
    while(Tasks--){
        int n;
        io >> n;
        long long ans2 = 0;
        while(n--){
            int K;
            io >> K;
            Fill(mex, 0);
            long long ans1 = 0;
            int cnt = 20 - K + 1, tot = 0;
            while(K--){
                int x;
                io >> x;
                mex[x] = 1;
            }
            R(i,1,20){
                if(!mex[i]){
                    if((--cnt) & 1) ans1 ^= tot;
                    tot = 0;
                }
                else
                    ++tot;
            }
            ans2 ^= ans1;
        }
        if(ans2)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

LuoguP2575 高手过招(博弈论)

标签:time   define   int   string   swa   type   str   reg   using   

原文地址:https://www.cnblogs.com/bingoyes/p/11710032.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!