Codeforces 993C Careful Maneuvering 位运算

C. Careful Maneuvering
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer yy-coordinates, and their xx-coordinate is equal to 100−100, while the second group is positioned in such a way that they all have integer yy-coordinates, and their xx-coordinate is equal to 100100.

Each spaceship in both groups will simultaneously shoot two laser shots (infinite ray that destroys any spaceship it touches), one towards each of the small spaceships, all at the same time. The small spaceships will be able to avoid all the laser shots, and now want to position themselves at some locations with x=0x=0 (with not necessarily integer yy-coordinates), such that the rays shot at them would destroy as many of the enemy spaceships as possible. Find the largest numbers of spaceships that can be destroyed this way, assuming that the enemy spaceships can't avoid laser shots.

Input

The first line contains two integers nn and mm (1n,m601≤n,m≤60), the number of enemy spaceships with x=100x=−100 and the number of enemy spaceships with x=100x=100, respectively.

The second line contains nn integers y1,1,y1,2,,y1,ny1,1,y1,2,…,y1,n (|y1,i|10000|y1,i|≤10000) — the yy-coordinates of the spaceships in the first group.

The third line contains mm integers y2,1,y2,2,,y2,my2,1,y2,2,…,y2,m (|y2,i|10000|y2,i|≤10000) — the yy-coordinates of the spaceships in the second group.

The yy coordinates are not guaranteed to be unique, even within a group.

Output

Print a single integer – the largest number of enemy spaceships that can be destroyed.

Examples
input
Copy
3 9
1 2 3
1 2 3 7 8 9 11 12 13
output
Copy
9
input
Copy
5 5
1 2 3 4 5
1 2 3 4 5
output
Copy
10
Note

In the first example the first spaceship can be positioned at (0,2)(0,2), and the second – at (0,7)(0,7). This way all the enemy spaceships in the first group and 66 out of 99 spaceships in the second group will be destroyed.

In the second example the first spaceship can be positioned at (0,3)(0,3), and the second can be positioned anywhere, it will be sufficient to destroy all the enemy spaceships.


自己用了vector和vis数组来做的,到了84就超时了,然后改用set,其实思路没什么变化,竟然就不超时了,这也非常的神奇,想必是第二次循环里省下了将近一半的时间吧,想必set内部是有什么神奇的机制(现在知道了,红黑树平衡二叉树),只是自己以前从来没想着去查。。。其实根据codeforces上的tag,应该用bitset才是,本来看见bitmask这个标签,还想着手动二进制状态压缩,数真的大。。。bitset用在这道题上巨好,因为有空间优化,还不用自己拿脑子想着里面的bit是什么样的。。。

还有,78个数据要注意,卡了中间只有一个位置的情况。。。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值