-
Notifications
You must be signed in to change notification settings - Fork 0
/
LOSTARRAY_.cpp
56 lines (53 loc) · 1005 Bytes
/
LOSTARRAY_.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
50
51
52
53
54
55
56
//https://www.codechef.com/problems/LOSTARRAY_
#include <iostream>
using std::cin;
using std::cout;
void Compute()
{
int n;
cin >> n;
int* B = new int[n + 1];
for(int i = 0; i < n + 1; i++)
{
cin >> B[i];
}
if (n % 2 == 0)
{
for (int i = 1; i < n + 1; i++)
{
cout << (B[0] ^ B[i]) << " ";
}
}
else
{
for (int i = 0; i < n + 1; i++)
{
int XoRs = 0;
for (int j = 0; j < n + 1; j++)
{
if (i != j)
XoRs ^= B[j];
}
if (XoRs == 0)
{
for (int j = 0; j < n + 1; j++)
{
if (i != j)
cout << (B[i] ^ B[j]) << " ";
}
break;
}
}
}
delete[] B;
}
int main() {
int T;
cin >> T;
while (T--)
{
Compute();
cout << "\n";
}
return 0;
}