blob: 386633002121c40b3048c0c4229bee9210bd42db (
plain) (
blame)
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
|
#include <iostream>
#include <vector>
using namespace std;
int
main()
{
int t, n;
long k;
cin >> t;
while (t--)
{
cin >> n >> k;
long d = k / n, m = k % n;
vector<long> a (n);
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < n / 2; ++i)
{
switch ((d + (m > i)) % 3)
{
case 1:
cout << (a[i] ^ a[n - i - 1]);
break;
case 2:
cout << a[n - i - 1];
break;
default:
cout << a[i];
}
cout << ' ';
}
if (n % 2)
cout << ((d + (m > n >> 1)) ? 0 : a[n >> 1]) << ' ';
for (int i = n - (n >> 1); i < n; ++i)
{
switch ((d + (m > i)) % 3)
{
case 1:
cout << a[n - i - 1];
break;
case 2:
cout << (a[i] ^ a[n - i - 1]);
break;
default:
cout << a[i];
}
cout << ((i + 1 == n) ? '\n' : ' ');
}
}
return 0;
}
|