bzoj 1228 [SDOI2009]E&D

sg表很好打,规律很不好找。。。。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
#define piii pair<int, pair<int,int> >

using namespace std;

const int N = 1e5 + 10;
const int M = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

int sg(int i, int j) {
    if((i & 1) && (j & 1)) return 0;
    return sg(i + 1 >> 1, j + 1 >> 1) + 1;
}
int n;
int main() {
    int T; scanf("%d", &T);
    while(T--) {
        int ans = 0;
        scanf("%d", &n);
        for(int i = 1; i <= n / 2; i++) {
            int x, y; scanf("%d%d", &x, &y);
            ans ^= sg(x, y);
        }
        if(ans) puts("YES");
        else puts("NO");
    }
    return 0;
}

/*
*/

 

posted @ 2018-06-03 18:55  NotNight  阅读(87)  评论(0编辑  收藏  举报