codeforces-scrape

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

2200E.md (1832B)


      1 Source: https://codeforces.com/problemset/problem/2200/E
      2 
      3 E. Divisive Battle
      4 
      5 time limit per test
      6 
      7 3 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Alice and Bob are playing game on array $a$ initially containing $n$ positive integers, with Alice going first.
     22 
     23 On each player's turn, if $a$ is non-decreasing$^{\text{∗}}$, the game immediately ends. Otherwise, the player can choose an element $x$ from the array and positive integers $1 \lt y,z \lt x$ such that $x=yz$ and replace $x$ in the array with two elements $y$ and $z$ (in any order at the original location of $x$). If no such move is possible, the game ends.
     24 
     25 Once the game ends, if $a$ is non-decreasing, then Bob wins. Otherwise, Alice wins. Determine who will win the game if both players play optimally.
     26 
     27 $^{\text{∗}}$$a$ is non-decreasing if $a_i\leq a_{i+1}$ for all $1\leq i\leq m-1$, where $m$ is the length of $a$.
     28 
     29 Input
     30 
     31 The first line contains an integer $t$ ($1 \leq t \leq 10^4$), the number of test cases.
     32 
     33 The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^5$).
     34 
     35 The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \leq a_i \leq 10^6$).
     36 
     37 The sum of $n$ over all test cases does not exceed $10^5$.
     38 
     39 Output
     40 
     41 For each test case, output a line containing "Alice" if Alice wins or "Bob" if Bob wins. The grader is case-sensitive.
     42 
     43 Example
     44 
     45 Input
     46 
     47 ```
     48 4
     49 
     50 10
     51 
     52 10 9 8 7 6 5 4 3 2 1
     53 
     54 3
     55 
     56 1 8192 677
     57 
     58 2
     59 
     60 6 5
     61 
     62 2
     63 
     64 6 7
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 Alice
     71 
     72 Bob
     73 
     74 Alice
     75 
     76 Bob
     77 ```
     78 
     79 Note
     80 
     81 In the first test case, Alice will win if both players play optimally.
     82 
     83 In the second test case, Bob can always win no matter what moves Alice makes.
     84 
     85 In the third test case, Alice can win by replacing $6$ with $3$ and $2$.
     86 
     87 In the fourth test case, the game ends immediately and Bob wins.