20pts,球条
查看原帖
20pts,球条
1151818
xxJoy0420楼主2025/7/1 22:26
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[100005],x,b[100005],top;
bool cz(long long x)
{
	long long l=0,r=m+1,mid;
	while(l+1<r)
	{
		mid=(l+r)>>1;
		if(x<b[mid]) r=mid;
		else if(x==b[mid]) break;
		else l=mid;
	}
	if(x==b[mid]) return true;
	return false;
}
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=m;i++) cin>>b[i];
	sort(a+1,a+1+n);
    sort(b+1,b+1+m);
	for(int i=1;i<=n;i++) if(cz(a[i])) cout<<a[i]<<" ";
	return 0;
} 
2025/7/1 22:26
加载中...