forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSequential Nim.cpp
49 lines (46 loc) · 916 Bytes
/
Sequential Nim.cpp
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
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
ll a[n];
for (ll i = 0; i < n; i++)
{
cin >> a[i];
}
int flag = 0;
for (ll i = 0; i < n; i++)
{
if (a[i] > 1 && i % 2 == 0)
{
cout << "First" << "\n";
flag = 1;
break;
}
else if (a[i] > 1 && i % 2 != 0)
{
cout << "Second" << "\n";
flag = 1;
break;
}
}
if (flag == 0)
{
if (n % 2 == 0)
{
cout << "Second" << "\n";
}
else
{
cout << "First" << "\n";
}
}
}
return 0;
}