加载中...

mulset等于一个有序数组放进去不查重

两个数组 需要让元素相等 每次操作让a变成她的数位 如1000->4
因为两次操作可以变成1 首先让一个数组变成2然后再是其他的
首先踢出相同元素 然后看着差不多就变成len扔进去
注意multiset排序 可以查不同元素
erase() 传入一个下标
find() 找到这个值出现的第一个位置

#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
#define int long long
#define double long double
#define endl '\n'



int t,n;
int len(int x){
	int cnt=0;
	while(x){
		cnt++;
		x/=10;
	}
	return cnt;
}
const int N=2e5+10;
int aa[N],bb[N];
signed main(){

	while(t--){
		int n;cin>>n;

		multiset<int>sa,sb,c,d; 
		for(int i=1;i<=n;i++){

			int x;
			cin>>x;
			sa.insert(x);
		}
		for(int i=1;i<=n;i++){
			int x;cin>>x;
			if(sa.find(x)==sa.end()){
				sb.insert(x);
			}else{
				sa.erase(sa.find(x));
			}
			
		}
		int res=0;
		for(auto x:sa){
			if(x>9) res++;
		}
		for(auto x:sb){
			if(x>9) res++;
		}
		
		for(auto x:sa){
			if(x>9) c.insert(len(x));
			else{
				c.insert((x));
			}
		}
		for(auto x:sb){
			int y=x>9?len(x):x;
			if(c.find(y)==c.end()) d.insert(y);
			else{
				c.erase(c.find(y));
			}
		}
		for(auto x:c) if(x!=1) res++;
    	for(auto x:d) if(x!=1) res++;
		
		
		
		cout<<res<<endl;
	}
	
	
	
	
	return 0;
}

posted @ 2022-09-11 23:31  liang302  阅读(26)  评论(0编辑  收藏  举报