代码
#include <iostream>
#include <cstdio>
#include <set>
#include <string>
using namespace std;
int main(){
string s,s2;
int l1,l2;
int cnt=0;
multiset<char> st;
cin>>s;
l1=s.length();
for(int i=0;s[i]!=NULL;i++){
st.insert(s[i]);
}
cin>>s2;
l2=s2.length();
for(int i=0;s2[i]!=NULL;i++){
if(st.find(s2[i])==st.end()){
cnt++;
}
else{
st.erase(st.find(s2[i]));
}
}
if(cnt==0){
cout<<"Yes"<<" "<<(l1-l2);
}
else{
cout<<"No"<<" "<<cnt;
}
return 0;
}
注意点
multiset中erase()和find()的用法。对于find(),如果没有找到,指向st.end()