codeforces 993c//Careful Maneuvering// Codeforces Round #488 by NEAR (Div. 1)
题意:x轴-100和+100的有敌人飞船,纵坐标由输入数据给出,我方有2飞船在x轴0,y坐标待定。0时刻时敌人同时向我方2飞船发出光线,光线会穿透飞船打到敌人自己,问2飞船放在哪敌人损失最大?
假如-100有飞船a,+100有飞船b,那么在两者y坐标和/2的位置放飞船,就炸掉2个。数据是60*60最多3600,将所有的和涉及的左飞船,右飞船或起来(位运算|)。然后二重循环和,或起来看数量。
//#pragma comment(linker,"/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<vector> #include<cmath> #include<queue> #include<stack> #include<map> #include<set> #include<algorithm> #include <stack> #include <bitset> using namespace std; const int SZ=50010,INF=0x7FFFFFFF; bitset<65> bt1[SZ],bt2[SZ]; int main() { std::ios::sync_with_stdio(0); //freopen("d:\\1.txt","r",stdin); //for(;scanf("%d",&n)!=EOF;) { int n,m; cin>>n>>m; vector<int> v1(n),v2(m); for(int i=0;i<n;++i)cin>>v1[i]; for(int i=0;i<m;++i)cin>>v2[i]; set<int> st; for(int i=0;i<n;++i) { for(int j=0;j<m;++j) { int val=v1[i]+v2[j]+20000; bt1[val][i]=1; bt2[val][j]=1; st.insert(val); } } int res=0; for(auto it=st.begin();it!=st.end();++it) { int cur=*it; for(auto j=st.begin();j!=st.end();++j) { //if(j==it)continue; int tmp=(bt1[cur]|bt1[*j]).count()+(bt2[cur]|bt2[*j]).count(); res=max(res,tmp); } } cout<<res<<endl; } return 0; }