题解 | #判断元素是否出现#

判断元素是否出现

https://www.nowcoder.com/practice/0787459e92bc4360ba48b094b7f21577

#include<bits/stdc++.h>
using namespace std;
int main(){
	//write your code here......
	int m,n,x,k;

	cin >> n >> m;
	map<int,string> ma;
	for(int i=0; i<n; i++){
		cin >>k;
		ma.insert(pair<int,string>(k,"yes"));
	}

	for(int i=0; i<m; i++){
		cin >>x;
		if(ma.find(x) == ma.end()){
			cout << "no"<< endl;
		}
		else
		{
			cout << "yes" << endl;
		}
	}

	return 0;
}

全部评论

相关推荐

刷牛客的单身狗很认真:全国可飞,支持007 上班时间,是吧?
点赞 评论 收藏
分享
双尔:反手回一个很抱歉,经过慎重考虑,您与我的预期暂不匹配,感谢您的投递
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务