文章

42

粉丝

0

获赞

35

访问

996

头像
动态查找问题 题解:map<int,int>
P1477
发布于2026年3月10日 12:08
阅读数 22

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	map<int,int> list;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t;//store temp
		cin>>t;
		list[t]=1;//t is in list;
	}
	int q;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int x;
		cin>>x;
		if(list.find(x)!=list.end())
		cout<<"find"<<endl;
		else{
			list[x]=1;
			cout<<"no"<<endl;
		}
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发