Lang:Java
Edit12345678910111213141516171819202122232425262728293031import java.util.*;public class Main{static class Node{Node up;Node down;Node left;Node right;int x;int y;}public static Node head;public static Node[] columnList;public static int n, m;public static int[][] arr;public static void init(){head = new Node();head.up = head.down = head.left = head.right = head;head.x = head.y = 0;columnList = new Node[m + 1];for(int i = 1; i <= m; i++)columnList[i] = new Node();}public static void build(){Node pre = head;Node p = null;//先把列头节点连起来for(int i = 1; i <= m; i++){