图案3

 如图有三种图案,需要绘制在一张画布上,画布左上角坐标(1,1)右下角坐标(L,L);

输入的数据T为测试用例的数量,数据N为图案的图案的数量,L为画布的边界值;

  1. 当图案的边界超出画布范围值,那么这个时候就不在绘制这个图案;
  2. 绘制图案时,图案与前一副图案有重合部分,那么就不在绘制该图案;

输出图案绘制完成画布中黄色, 蓝色,紫色的数量;

static int T, N, L;
static int[] x;
static int[] y;
static int[] z;
static int Yellow;
static int Blue;
static int Purple;

/**
 * @param args
 */

public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    T = sc.nextInt();
    for (int case_test = 1; case_test < T + 1; case_test++) {
        N = sc.nextInt(); // 花朵数量
        L = sc.nextInt(); //
        for (int i = 1; i < N + 1; i++) {
            x[i] = sc.nextInt(); // 花园的横坐标
            y[i] = sc.nextInt(); // 花园的纵坐标
            z[i] = sc.nextInt(); // 花的类型
        }
        Yellow = 0;
        Blue = 0;
        Purple = 0;
        //此处添加方法
        System.out.println(“#” + case_test + ” ” + Yellow + ” ” + Blue + ” ” + Purple);
    }
}

 

 

 

1(测试用例1

2 5 2表示需要绘制两朵,5表示画布边界)

1 2 1(第一朵花,分别表示坐标为(1,2)已经花的类型为1

2 2 1(第二朵花,分别表示坐标为(2,2)已经花的类型为1

输出结果

#1 4 0 0 #1表示用例1,4表示黄色4个, 蓝色0个,紫色0个)

版权声明:本文为johnny-ylp原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/johnny-ylp/p/11994163.html