import java.util.*; public class RobotRouting { static final long startTime = System.currentTimeMillis(); static final Random rand = new Random(12345); static final int INF = 100000000; static final int MAXT = 50000; static final int TIMESLOT = 500; static final int timeSinceStart() { return (int)(System.currentTimeMillis()-startTime)/100; } String[] route(int C, int M, int N, int K, int rowGap, int colGap, int[] robotX, int[] robotY, String[] prods, int[] taskID, int[] taskY) { boolean lanes = C <= 5; String[] ans = null; int bestVal = 1000000002; int rounds = 0; while (true) { ++rounds; RealDeal rd = new RealDeal(); rd.lanes = lanes; lanes = !lanes; String[] alt = rd.route(C, M, N, K, rowGap, colGap, robotX, robotY, prods, taskID, taskY); int score; if (rd.completedTasks == 0) { score = 1000000001; } else if (rd.completedTasks == 10000) { score = alt.length; } else { score = 1000000000/rd.completedTasks; } if (score < bestVal) { bestVal = score; ans = alt; } int time = timeSinceStart(); int timeEstimate = ((rounds+1)*time)/rounds; if (timeEstimate+40 >= TIMESLOT) break; } return ans; } static class Position { final int x, y; Position(int x, int y) { this.x = x; this.y = y; } @Override public String toString() { return "("+x+","+y+")"; } } static enum Dir { R(1, 0), U(0, -1), D(0, 1), L(-1, 0); final int dx, dy; final String action; Dir opposite; Dir(int dx, int dy) { this.dx = dx; this.dy = dy; action = toString(); } } static { Dir.U.opposite = Dir.D; Dir.D.opposite = Dir.U; Dir.L.opposite = Dir.R; Dir.R.opposite = Dir.L; } static final Dir[] dirs = {Dir.R, Dir.U, Dir.D, Dir.L}; static enum MoveState { STAY, LOADING, WANT_TO_GO, PROCESSING, MOVED; } static enum Phase { OUT, DELIVERY, DONOTHING; } static class Option implements Comparable