File size: 1,590 Bytes
c4b0eef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
/*
****************************************************************
****************************************************************
-> Coded by Stavros Chryselis
-> Visit my github for more solved problems over multiple sites
-> https://github.com/StavrosChryselis
-> Feel free to email me at [email protected]
****************************************************************
****************************************************************
*/
#include <stdio.h>
#include <ctype.h>
#define gc() getchar_unlocked()
#define MAXN 100000
#define MAXM 30
using namespace std;
int N, M;
int DP[MAXN + 7];
int steps[MAXM + 7];
inline int FAST_IO()
{
char ch;
int val = 0;
ch = gc();
while (isspace(ch) && ch != EOF)
ch = gc();
val = 0;
while (isdigit(ch))
{
val = (val * 10) + (ch - '0');
ch = gc();
}
return val;
}
inline void init()
{
int i;
N = FAST_IO();
M = FAST_IO();
for (i = 0; i < M; i++)
steps[i] = FAST_IO();
}
inline int grundy(int pos)
{
int i;
bool a[50] = { 0 };
for (i = 0; i < M; i++)
if (steps[i] <= pos)
a[DP[pos - steps[i]]] = 1;
for (i = 0; i < 50; i++)
if (!a[i])
return i;
return 0;
}
inline void calc_dp()
{
int i;
for (i = 1; i <= MAXN; i++)
DP[i] = grundy(i);
}
inline bool solve()
{
int num, rval = 0;
while (N--)
{
num = FAST_IO();
rval ^= DP[num];
}
return rval;
}
int main()
{
int T;
// freopen("input.txt", "r", stdin);
T = FAST_IO();
while (T--)
{
init();
calc_dp();
if (!solve())
printf("Vinit\n");
else
printf("Ada\n");
}
return 0;
}
|