Codeforces 1383B GameGame(博弈)
题意:长度为n的数组a,Va=Vb=0,先手选出一个a【i】xor Va,后手同理,,Va>Vb为胜利,给出a【】问必胜,必败还是平局。
题解:https://codeforces.com/blog/entry/80562
#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(false);cin.tie(0) #define fre freopen("C:\\in.txt", "r", stdin) #define _for(i,a,b) for(int i=a; i< b; i++) #define _rep(i,a,b) for(int i=a; i<=b; i++) #define lowbit(a) ((a)&-(a)) #define inf 0x3f3f3f3f #define endl "\n" using namespace std; typedef long long ll; template <class T> void read(T &x) { char c; bool op=0; while(c=getchar(), c<'0'||c>'9') if(c=='-') op=1; x=c-'0'; while(c=getchar(), c>='0'&&c<='9') x=x*10+c-'0'; if(op) x=-x; } const int maxn=1e5+5; int T, n, a[maxn]; int main() { //fre; read(T); while(T--) { read(n); int x=0, k=30; _rep(i, 1, n) read(a[i]), x^=a[i]; if(!x){ printf("DRAW\n"); continue; } while(!(x>>k&1)) k--; //printf("k=%d\n", k); vector<int> f(2); _rep(i, 1, n) f[a[i]>>k&1]++; if(f[1]%4==3 && f[0]%2==0) printf("LOSE\n"); else printf("WIN\n"); } return 0; }