标签:i++ climits getch || local har pair sig map
首先可以发现,若是后手能赢,那么先手取后手的值,一定能赢,所以首先排除后手胜。
对于平局,当且仅当,所有异或值为零,无论怎么取,双方均相等。剩下的便是先手胜利。
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<bitset>
#include<map>
//#include<regex>
#include<cstdio>
#pragma GCC optimize(2)
#define up(i,a,b) for(int i=a;i<b;i++)
#define dw(i,a,b) for(int i=a;i>b;i--)
#define upd(i,a,b) for(int i=a;i<=b;i++)
#define dwd(i,a,b) for(int i=a;i>=b;i--)
//#define local
typedef long long ll;
typedef unsigned long long ull;
const double esp = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int inf = 1e9;
using namespace std;
ll read()
{
char ch = getchar(); ll x = 0, f = 1;
while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
return x * f;
}
typedef pair<int, int> pir;
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lrt root<<1
#define rrt root<<1|1
int n, T;
const int N = 1e5 + 10;
int a[N];
map<int, int>mp;
int main()
{
T = read();
while (T--)
{
int sum = 0;
bool flag = 1;
n = read();
upd(i, 1, n)a[i] = read(),sum^=a[i];
int u, v;
upd(i, 1, n - 1)u = read(), v = read();
if (sum == 0)printf("D\n");
else printf("Q\n");
}
return 0;
}
标签:i++ climits getch || local har pair sig map
原文地址:https://www.cnblogs.com/LORDXX/p/12520356.html