蚂蚁爬杆问题

蚂蚁爬杆问题
 有一根27厘米长的细木杆,在第3厘米,7厘米,11厘米,17厘米,23厘米这五个位置上各有一只蚂蚁,木杆很细,不能同时通过两只蚂蚁,开始时,蚂蚁的头朝向左还是右是任意的,他们只会朝前走或掉头,但不会后退,当两只蚂蚁相遇后,蚂蚁会同时掉头朝反方向走,假设蚂蚁们每秒钟可以走1厘米的距离。求所有蚂蚁都离开木杆的最小时间和最大时间。
 答案:
 两只蚂蚁相遇后,各自掉头朝相反方向走。如果我们不考虑每个蚂蚁的具体身份,这和两只蚂蚁相遇后,打个招呼继续向前走没有什么区别。
 所有蚂蚁都离开木杆的最小时间为
 max(min(3,27-3),min(7,27-7), min(11,27-11), min(17,27-17),min(23,27-23))=11
 所有蚂蚁都离开木杆的最大时间为

 max(max(3,27-3),max(7,27-7), max(11,27-11), max(17,27-17),max(23,27-23))=24

蚂蚁类:

public class Ant implements Cloneable{
//	蚂蚁所在的位置
	private int x;
//	蚂蚁行走的方向1 向右 2 向左 
	private int dir;
	Ant(int x,int dir)
	{
		this.x=x;
		this.dir=dir;
	}
	
	public int getDir() {
		return dir;
	}

	public void setDir(int dir) {
		this.dir = dir;
	}

	public int getX() {
		return x;
	}
	
	public void changeDir()
	{
		if(dir==1)
		{
			dir=2;
		}else if(dir==2){
			dir=1;
		}
	}

	public void update(int _x)
	{
		if(dir==2)
		{
			this.x-=_x;
		}else if(dir==1){
			this.x+=_x;
		}else{
			try {
				throw new Exception("未知方向");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		Ant _a=(Ant) super.clone();
		Ant a=new Ant(_a.getX(), _a.getDir());
		return a;
	}

	@Override
	public String toString() {
		return "Ant [dir=" + dir + ", x=" + x + "]";
	}
}

一组蚂蚁类:

import java.util.Stack;


public class AntGroup implements Cloneable{
	private Stack<Ant> ants;
	
	public Stack<Ant> getAnts() {
		return ants;
	}
	public AntGroup()
	{
		ants=new Stack<Ant>();
	}
	public void addAnt(Ant a)
	{
		if(ants==null){
			ants=new Stack<Ant>();
		}
		ants.add(a);
	}
	
//  讲protected类型改成public类型  
    @Override  
    public Object clone() throws CloneNotSupportedException {  
//      super.clone()只能实现浅复制  
        Object obj=super.clone();  
//      该方法实现深复制  
        AntGroup t=(AntGroup) obj;  
        AntGroup _ag=new AntGroup();
        for(int i=0;i<t.getAnts().size();i++)
        {
        	_ag.addAnt((Ant)t.getAnts().get(i).clone());
        }
        return _ag;  
    }
	@Override
	public String toString() {
		return "AntGroup [ants=" + ants + "]";
	} 
    
}

工具类:

import java.util.Stack;


public class Util {
	/*
	 * 判断是否相撞
	 */
	public static boolean iscollide(Ant a1,Ant a2)
	{
		if(a1.getDir()!=a2.getDir()&&((a1.getDir()==2&&(a1.getX()-1==a2.getX()))||a1.getDir()==1&&(a1.getX()+1==a2.getX())))
		{
			a1.changeDir();
			a2.changeDir();
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 * 判断多个对象碰撞事件
	 * @param a1
	 * @return
	 */
	public static void iscollides(AntGroup ag)
	{
		Stack<Ant> sa=ag.getAnts();
		for(int i=0;i<sa.size();i++)
		{
			for(int j=i+1;j<sa.size();j++)
			{
				iscollide(sa.get(i),sa.get(j));
			}
		}
	}
	
	/**
	 * 清除超出范围的蚂蚁
	 * @param a1
	 * @return
	 */
	public static void Refresh(AntGroup ag)
	{
		Stack<Ant> sa=ag.getAnts();
		for(int i=0;i<sa.size();i++)
		{
			if(isOutBar(sa.get(i)))
			{
				ag.getAnts().remove(i);
				--i;
			}
		}
	}
	
	
	/*
	 * 是否走出细木杆
	 */
	public static boolean isOutBar(Ant a1)
	{
		if(a1.getX()>27||a1.getX()<0)
		{
			return true;
		}else{
			return false;
		}
	}
}

主方法,测试类:

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;


public class testJ {

	
	public static int count=0;
	static int x[]={3,7,11,17,23};
	static int dir[]={1,2};
	static List<Ant> as=new ArrayList<Ant>(x.length);
	/**
	 * 有一根27厘米长的细木杆,在第3厘米,7厘米,11厘米,17厘米,23厘米这五个位置上各有一只蚂蚁,
	 * 木杆很细,不能同时通过两只蚂蚁,开始时,
	 * 蚂蚁的头朝向左还是右是任意的,他们只会朝前走或掉头,但不会后退,当两只蚂蚁相遇后,蚂蚁会同时掉头朝反方向走,假设蚂蚁们每秒钟可以走1厘米的距离。
	 * 求所有蚂蚁都离开木杆的最小时间和最大时间。
	 * @param args
	 */
	public static void main(String[] args) {
		testJ tj=new testJ();
		Stack<AntGroup> ags = CollectionAntGroup(tj);
		Stack<AntGroup> ags1 = CollectionAntGroup(tj);
		System.out.println("初始蚂蚁的方向:"+ags.size()+"种");
		tj.updateTime(ags1.get(tj.MinTime(ags)));
		System.out.println("---------------------------------");
		tj.updateTime(ags1.get(tj.MaxTime(ags)));
		
	}
	
	public void updateTime(AntGroup ag)
	{
		int i=0;
		while(ag.getAnts().size()!=0)
		{
			++i;
			Util.iscollides(ag);
			for(Ant as:ag.getAnts())
			{
				as.update(1);
			}
			Util.Refresh(ag);
		}
		System.out.println("总共走了"+i+"次");
	}
	

	private static Stack<AntGroup> CollectionAntGroup(testJ tj) {
		Stack<AntGroup> ags=new Stack<AntGroup>();
		AntGroup ag=new AntGroup();
		try {
			tj.getAntGroup(ags,ag,0,0);
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return ags;
	}
	
	public void getAntGroup(Stack<AntGroup> ags,AntGroup ag,int xl,int dirl) throws CloneNotSupportedException
	{
		Ant _a;
			for(int j=dirl;j<dir.length&&xl<x.length;j++)
			{
				_a=new Ant(x[xl], dir[j]);
				ag.addAnt((Ant)_a.clone());
				if(xl==x.length-1)
				{
					AntGroup _ag;
						_ag = (AntGroup) ag.clone();
						System.out.println("插入AntGroup"+_ag);
						ags.add(_ag);
				}
				getAntGroup(ags,ag,xl+1,dirl);
				ag.getAnts().pop();
			}
	}
	
	/**
	 * 所有蚂蚁离开木杆的最小时间
	 * 按层次遍历
	 */
	public int MinTime(Stack<AntGroup> ags)
	{
		while(isMinTimeLocal(ags)==-1)
		{
			for(AntGroup ag:ags)
			{
				Util.iscollides(ag);
				for(Ant as:ag.getAnts())
				{
					as.update(1);
				}
				Util.Refresh(ag);
			}
		}
		System.out.println(ags);
		return isMinTimeLocal(ags);
	}
	/**
	 * 所有蚂蚁离开木杆的最大时间
	 * 按层次遍历
	 */
	public int MaxTime(Stack<AntGroup> ags)
	{
		while(isMaxTimeLocal(ags)==-1)
		{
			for(AntGroup ag:ags)
			{
				Util.iscollides(ag);
				for(Ant as:ag.getAnts())
				{
					as.update(1);
				}
				Util.Refresh(ag);
			}
		}
		System.out.println(ags);
		return isMaxTimeLocal(ags);
	}
	
	public int isMinTimeLocal(Stack<AntGroup> ags)
	{
		for(int i=0;i<ags.size();i++)
		{
			if(ags.get(i).getAnts().size()==0)
			{
				return i;
			}
		}
		return -1;
	}
	public int isMaxTimeLocal(Stack<AntGroup> ags)
	{
		for(int i=0;i<ags.size();i++)
		{
			if(ags.get(i).getAnts().size()!=0)
			{
				return i;
			}
		}
		return -1;
	}
}

测试结果:

插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=1, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=1, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=1, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=1, x=17], Ant [dir=2, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=1, x=23]]]
插入AntGroupAntGroup [ants=[Ant [dir=2, x=3], Ant [dir=2, x=7], Ant [dir=2, x=11], Ant [dir=2, x=17], Ant [dir=2, x=23]]]
初始蚂蚁的方向:32种
[AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=1, x=23]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=23]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=23], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=23], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=23], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=1, x=23]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=19]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=23]]], AntGroup [ants=[Ant [dir=1, x=23], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=23], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=23], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[]], AntGroup [ants=[Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=2, x=5], Ant [dir=2, x=11]]]]
总共走了12次
---------------------------------
[AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=1, x=23]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=19], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=23]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=23], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=23], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=1, x=23], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=15], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=1, x=23]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=1, x=23], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=19]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=19], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=23]]], AntGroup [ants=[Ant [dir=1, x=23], Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=1, x=23], Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=1, x=23], Ant [dir=2, x=5], Ant [dir=2, x=11]]], AntGroup [ants=[]], AntGroup [ants=[Ant [dir=2, x=11]]], AntGroup [ants=[Ant [dir=2, x=5]]], AntGroup [ants=[Ant [dir=2, x=5], Ant [dir=2, x=11]]]]
总共走了25次




评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值