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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#include <stdio.h>
/* For the sake of performance */
long a[50000], b[50000];
void longxor(long n)
{
long i, all = 0, almost = 0, vacancy = 0;
for (i = 0; i < n; i++) {
printf("1 %ld %ld %ld\n",
i + 1, (i + 1) % n + 1, (i + 2) % n + 1);
fflush(stdout);
scanf("%ld", b + i);
all ^= b[i];
}
for (i = 2 - n % 3; i < n; i += 3)
almost ^= b[i];
for (i = 0; i < n; i++) {
a[vacancy] = all ^ almost;
all ^= b[vacancy] ^ b[(vacancy + 1) % n];
vacancy = (vacancy + 3) % n;
}
}
void fourxor(long n)
{
printf("1 %ld %ld %ld\n", n - 2, n - 1, n);
fflush(stdout);
scanf("%ld", b);
printf("1 %ld %ld %ld\n", n - 3, n - 1, n);
fflush(stdout);
scanf("%ld", b + 1);
printf("1 %ld %ld %ld\n", n - 3, n - 2, n);
fflush(stdout);
scanf("%ld", b + 2);
printf("1 %ld %ld %ld\n", n - 3, n - 2, n - 1);
fflush(stdout);
scanf("%ld", b + 3);
long all = b[0] ^ b[1] ^ b[2] ^ b[3];
a[n - 4] = all ^ b[0];
a[n - 3] = all ^ b[1];
a[n - 2] = all ^ b[2];
a[n - 1] = all ^ b[3];
}
int main()
{
long t, n, i = 1;
scanf("%ld", &t);
while (t-- && i == 1) {
scanf("%ld", &n);
if (n % 3) {
longxor(n);
} else {
longxor(n - 4);
fourxor(n);
}
putchar(50);
for (i = 0; i < n; i++)
printf(" %ld", a[i]);
putchar(10);
fflush(stdout);
scanf("%ld", &i);
}
return 0;
}
|