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.
The first line contains two integers nn and mm (1≤n,m≤601≤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.
Print a single integer – the largest number of enemy spaceships that can be destroyed.
3 9 1 2 3 1 2 3 7 8 9 11 12 13
9
5 5 1 2 3 4 5 1 2 3 4 5
10
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个数据要注意,卡了中间只有一个位置的情况。。。