蓝桥2019轨道炮

package javaa2019;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Scanner;

public class 轨道炮 {
	static int n;
	static PLAN plan[];
	static long max = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		plan = new PLAN[n];
		sc.nextLine();
		for(int i = 0;i<plan.length;i++){
			String srr[] = sc.nextLine().split(" ");
			plan[i] = new PLAN(Long.parseLong(srr[0]),Long.parseLong(srr[1]),Long.parseLong(srr[2]),srr[3]);			
		}
		Calendar st = Calendar.getInstance();
		max = count();
		for(int d = 0;d<50000;d++){
			fly();
			long dd = count();
			if(dd>max)
				max = dd;
		}
		System.out.println(max);
		Calendar en = Calendar.getInstance();
//		System.out.println(en.getTimeInMillis()-st.getTimeInMillis());
		
	}
	static void fly(){
		for(int i = 0;i<plan.length;i++){
			String fl = plan[i].drirect;
			if(fl.equals("R"))
				plan[i].x+=plan[i].v;
			if(fl.equals("L"))
				plan[i].x-=plan[i].v;
			if(fl.equals("U"))
				plan[i].y+=plan[i].v;
			if(fl.equals("D"))
				plan[i].y-=plan[i].v;
		}
	}
	
	static long count(){
		HashMap<Long, Long> xHashMap = new HashMap<Long, Long>();
		HashMap<Long, Long> yHashMap = new HashMap<Long, Long>();
		for(int i = 0;i<plan.length;i++){
			long x = plan[i].x;
			long y = plan[i].y;
			xHashMap.put(x,xHashMap.containsKey(x)?xHashMap.get(x)+1:1);
			yHashMap.put(y,yHashMap.containsKey(y)?yHashMap.get(y)+1:1);
		}
		long max = 0;
		for(long i:xHashMap.keySet())
			if(xHashMap.get(i)>max)
				max = xHashMap.get(i);
		for(long i:yHashMap.keySet())
			if(yHashMap.get(i)>max)
				max = yHashMap.get(i);
		return max;
	}
}
class PLAN{
	long x;
	long y;
	long v;
	String drirect;
	public PLAN(Long x,Long y,long l,String di){
		this.x = x;
		this.y = y;
		this.v = l;
		this.drirect = di;
	}
	@Override
	public String toString() {
		return "PLAN [drirect=" + drirect + ", v=" + v + ", x=" + x + ", y="
				+ y + "]";
	}
	
}
//4
//0 0 1 R
//0 10 1 R
//10 10 2 D
//2 3 2 L

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值