题意:
思路:
1 #include <stdio.h> 2 #include <vector> 3 #include <algorithm> 4 #include <string.h> 5 #include <limits.h> 6 #include <string> 7 #include <iostream> 8 #include <queue> 9 #include <math.h> 10 #include <stack> 11 #include <map> 12 #define left (now<<1) 13 #define right ((now<<1)+1) 14 #define mid ((l+r)>>1) 15 using namespace std; 16 typedef long long int lint; 17 18 const int MAXN = 1e5 + 10; 19 20 int t,n,m; 21 int p[40]; 22 23 void chai(int num){ 24 for(int i = 0; i <= 31; ++i){ 25 int k = num & 1; 26 num = num >> 1; 27 if(k == 1){ p[i]++;} 28 } 29 } 30 31 int main(){ 32 scanf("%d",&t); 33 while(t--){ 34 scanf("%d",&n); memset(p,0,sizeof(p)); 35 for(int i = 1; i <= n; ++i){ 36 int num; scanf("%d",&num); chai(num); 37 } 38 for(int i = 1; i < n; ++i){ 39 int u,v; scanf("%d%d",&u,&v); 40 } 41 int can = -1;; 42 for(int i = 31; i >= 0; --i){ 43 if(p[i] % 2 == 1){ 44 can = 1; break; 45 } 46 } 47 // for(int i = 0; i <= 4; ++i){ 48 // printf("%d ",p[i]); 49 // } 50 if(can == -1){ 51 printf("D "); 52 }else{ 53 printf("Q "); 54 } 55 } 56 return 0; 57 }