题目要求
P1847题目链接
这题数据量明显upupup,所以就不能按照轰炸III的思路去做,否则就爆了……
交完代码AC以后,我看题解区那里各种优化,我就很困惑,何必呢?
看到本题没给N*M界限的时候,就应该明白思路变化了,更何况数据的up,我们不妨先开四个小数组存起来坐标,根据同索引可以对应起来。
最后读一下关键点的坐标,再倒着遍历四个点,看看关键点在不在轰炸区范围内,不就好了?
有时候,换个思维,一切都很简单,只需要O(N2)呀……
AC代码(Java语言描述)import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
short times = scanner.nextShort(), num = scanner.nextShort();
long[] x1_array = new long[times+1];
long[] y1_array = new long[times+1];
long[] x2_array = new long[times+1];
long[] y2_array = new long[times+1];
for (int i = 1; i = x0 && x1_array[j] = y0 && y1_array[j]
关注
打赏
热门博文
- 【Linux】Ubuntu20.04安装和卸载MySQL8
- 【Linux】Ubuntu 20.04 报错 curl: (23) Failure writing output to destination 的解决方法
- 【Java】JUnit 4.13.2 警告 ‘assertEquals(double, double)‘ is deprecated 的解决方法
- 【JavaScript】处理 @parcel/transformer-js: Browser scripts cannot have imports or exports.
- 【Node.js】Windows环境安装配置NVM和Node.js
- 【Python】处理TypeError: Plain typing.NoReturn is not valid as type argument
- 【Python】Matplotlib可视化50例
- 【C语言】C语言修改MySQL数据库
- 【Java】从默认包导入类和对象报错的解决方法
- 【Java】panel.getGraphics()报错空指针异常的解决方法