codeforces-scrape

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

1847C.md (2442B)


      1 Source: https://codeforces.com/problemset/problem/1847/C
      2 
      3 C. Vampiric Powers, anyone?
      4 
      5 time limit per test
      6 
      7 1 second
      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 [DIO](https://jojowiki.com/Dio_Brando) knows that the Stardust Crusaders have determined his location and will be coming to fight him. To foil their plans he decides to send out some [Stand](https://jojo.fandom.com/wiki/Stand) users to fight them. Initially, he summoned $n$ Stand users with him, the $i$-th one having a strength of $a_i$. Using his vampiric powers, he can do the following as many times as he wishes:
     22 
     23 * Let the current number of Stand users be $m$.
     24 * DIO chooses an index $i$ ($1 \le i \le m$).
     25 * Then he summons a new Stand user, with index $m+1$ and strength given by: $$a_{m+1} = a_i \oplus a_{i+1} \oplus \ldots \oplus a_m,$$
     26 
     27   where the operator $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
     28 * Now, the number of Stand users becomes $m+1$.
     29 
     30 Unfortunately for DIO, by using Hermit Purple's divination powers, the Crusaders know that he is plotting this, and they also know the strengths of the original Stand users. Help the Crusaders find the maximum possible strength of a Stand user among all possible ways that DIO can summon.
     31 
     32 Input
     33 
     34 Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10\,000$). The description of the test cases follows.
     35 
     36 The first line of each test case contains a single integer $n$ ($1 \le n \le 10^5$)  – the number of Stand users initially summoned.
     37 
     38 The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \lt 2^8$)  – the strength of each Stand user.
     39 
     40 It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.
     41 
     42 Output
     43 
     44 For each test case, output a single integer, maximum strength of a Stand user among all possible ways that DIO can summon.
     45 
     46 Example
     47 
     48 Input
     49 
     50 ```
     51 3
     52 
     53 4
     54 
     55 0 2 5 1
     56 
     57 3
     58 
     59 1 2 3
     60 
     61 5
     62 
     63 8 2 4 12 1
     64 ```
     65 
     66 Output
     67 
     68 ```
     69 7
     70 3
     71 14
     72 ```
     73 
     74 Note
     75 
     76 In the first test case, one of the ways to add new Stand users is as follows:
     77 
     78 * Choose $i=n$. Now, $a$ becomes $[0,2,5,1,1]$.
     79 * Choose $i=1$. Now, $a$ becomes $[0,2,5,1,1,7]$. $7$ is the maximum strength of a Stand user DIO can summon.
     80 
     81 In the second test case, DIO does not need to add more Stand users because $3$ is the maximum strength of a Stand user DIO can summon.