您当前的位置: 首页 >  蓝桥杯

不牌不改

暂无认证

  • 0浏览

    0关注

    422博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

蓝桥杯算法训练VIP-集合运算

不牌不改 发布时间:2021-08-08 23:52:43 ,浏览量:0

题目

题目链接

题解

实现题。

用map实现,因为集合中的值太大做不了数组索引,因此用map。

因为要求差集就还要单独存一下a中的元素,用的vector。

代码
#include
using namespace std;

int n, s, m, num, ans[2010];
map cnt;
vector a;

int main()
{
	cin>>n;
	for(int i = 1;i >s, cnt[s] ++, a.push_back(s);
	cin>>m;
	for(int i = 1;i >s, cnt[s] ++;
	
	for(map::iterator it = cnt.begin();it != cnt.end();it ++) 
	if(it->second == 2) ans[num++] = it->first;
	
	sort(ans, ans+num);
	for(int i = 0;i             
关注
打赏
1662186765
查看更多评论
0.9536s