codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1738C.md (1823B)


      1 Source: https://codeforces.com/problemset/problem/1738/C
      2 
      3 C. Even Number Addicts
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 512 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Alice and Bob are playing a game on a sequence $a_1, a_2, \dots, a_n$ of length $n$. They move in turns and Alice moves first.
     22 
     23 In the turn of each player, he or she should select an integer and remove it from the sequence. The game ends when there is no integer left in the sequence.
     24 
     25 Alice wins if the sum of her selected integers is even; otherwise, Bob wins.
     26 
     27 Your task is to determine who will win the game, if both players play optimally.
     28 
     29 Input
     30 
     31 Each test contains multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 100$) — the number of test cases. The following lines contain the description of each test case.
     32 
     33 The first line of each test case contains an integer $n$ ($1 \leq n \leq 100$), indicating the length of the sequence.
     34 
     35 The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($-10^9 \leq a_i \leq 10^9$), indicating the elements of the sequence.
     36 
     37 Output
     38 
     39 For each test case, output "Alice" (without quotes) if Alice wins and "Bob" (without quotes) otherwise.
     40 
     41 Example
     42 
     43 Input
     44 
     45 ```
     46 4
     47 
     48 3
     49 
     50 1 3 5
     51 
     52 4
     53 
     54 1 3 5 7
     55 
     56 4
     57 
     58 1 2 3 4
     59 
     60 4
     61 
     62 10 20 30 40
     63 ```
     64 
     65 Output
     66 
     67 ```
     68 Alice
     69 Alice
     70 Bob
     71 Alice
     72 ```
     73 
     74 Note
     75 
     76 In the first and second test cases, Alice always selects two odd numbers, so the sum of her selected numbers is always even. Therefore, Alice always wins.
     77 
     78 In the third test case, Bob has a winning strategy that he always selects a number with the same parity as Alice selects in her last turn. Therefore, Bob always wins.
     79 
     80 In the fourth test case, Alice always selects two even numbers, so the sum of her selected numbers is always even. Therefore, Alice always wins.