3 import static java
.lang
.System
.out
;
7 static final int UNDEFINED
= -1;
9 int ask(int i
, int j
, int k
) {
10 out
.println((i
+ 1) + " " + (j
+ 1) + " " + (k
+ 1));
15 Queue
<Integer
> decide(int[] a
, int l
, Queue
<Integer
> queue
) {
16 while (queue
.size() > 2) {
21 int za
= ask(l
, x
, y
);
22 int xa
= ask(l
, y
, z
);
23 int ya
= ask(l
, z
, x
);
44 Queue
<Integer
> take(int[] a
, int value
) {
45 Queue
<Integer
> result
= new LinkedList
<Integer
>();
46 for (int i
= 0; i
< a
.length
; i
++) {
54 int[] askAll(int n
, int l
, int r
) {
56 for (int i
= 0; i
< n
; i
++) {
57 a
[i
] = (i
== l
|| i
== r
) ? UNDEFINED
: ask(l
, r
, i
);
62 void run() throws IOException
{
65 out
.println("OK 1 2 3");
69 for (int j
= 1; j
< n
; j
++) {
70 int[] a
= askAll(n
, 0, j
);
74 for (int i
= 0; i
< n
; i
++) {
75 if (min
== UNDEFINED
&& a
[i
] != UNDEFINED
|| min
> a
[i
]) {
78 if (max
== UNDEFINED
&& a
[i
] != UNDEFINED
|| max
< a
[i
]) {
84 Queue
<Integer
> other
= decide(a
, 0, take(a
, max
));
88 a
[other
.remove()] = n
- 1;
89 a
[other
.remove()] = n
;
91 a
[other
.remove()] = 1;
92 a
[other
.remove()] = 2;
97 Queue
<Integer
> less
= decide(a
, 0, take(a
, min
));
98 Queue
<Integer
> greater
= decide(a
, 0, take(a
, max
));
99 int l
= less
.remove();
100 int r
= greater
.remove();
101 if (!less
.isEmpty()) {
102 int p
= less
.remove();
103 if (p
!= 0 && p
!= j
) {
107 if (!greater
.isEmpty()) {
108 int p
= greater
.remove();
109 if (p
!= 0 && p
!= j
) {
116 if (a
[0] == UNDEFINED
) {
119 if (a
[j
] == UNDEFINED
) {
133 public static void main(String
[] args
) throws Exception
{
134 in
= new Scanner(System
.in
);
136 new central_gk().run();