99 lines
1.8 KiB
Java
99 lines
1.8 KiB
Java
package chelper;
|
|
|
|
import java.util.Objects;
|
|
import java.util.TreeSet;
|
|
|
|
import io.InputReader;
|
|
import io.OutputWriter;
|
|
|
|
|
|
public class TaskC {
|
|
|
|
|
|
class Point implements Comparable<Point> {
|
|
public final int x;
|
|
public final int y;
|
|
|
|
public Point(int x, int y) {
|
|
this.x = x;
|
|
this.y = y;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
Point point = (Point) o;
|
|
return x == point.x &&
|
|
y == point.y;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(x, y);
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(Point o) {
|
|
int t = Integer.compare(x, o.x);
|
|
if (t != 0) {
|
|
return t;
|
|
}
|
|
return Integer.compare(y, o.y);
|
|
}
|
|
}
|
|
|
|
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
|
int area = in.nextInt();
|
|
|
|
int w, h;
|
|
|
|
int offsetX = 100;
|
|
int offsetY = 100;
|
|
|
|
if (area == 20) {
|
|
w = 5;
|
|
h = 4;
|
|
} else {
|
|
w = 20;
|
|
h = 10;
|
|
}
|
|
|
|
TreeSet<Point> missing = new TreeSet<>();
|
|
|
|
for (int i = 0; i < w; i++) {
|
|
for (int j = 0; j < h; j++) {
|
|
missing.add(new Point(i, j));
|
|
}
|
|
}
|
|
|
|
while (!missing.isEmpty()) {
|
|
Point p = missing.first();
|
|
|
|
int x = p.x + 1;
|
|
int y = p.y;
|
|
|
|
x = Math.max(1, Math.min(w - 2, x)) + offsetX;
|
|
y = Math.max(1, Math.min(h - 2, y)) + offsetY;
|
|
|
|
out.println(x + " " + y);
|
|
out.flush();
|
|
|
|
int xi = in.nextInt();
|
|
int yi = in.nextInt();
|
|
|
|
if (xi == -1 && yi == -1) {
|
|
throw new RuntimeException("something's bad");
|
|
}
|
|
|
|
if (xi == 0 && yi == 0) {
|
|
break;
|
|
}
|
|
|
|
Point p2 = new Point(xi - offsetX, yi - offsetY);
|
|
|
|
missing.remove(p2);
|
|
}
|
|
}
|
|
}
|