fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. ios::sync_with_stdio(false);
  8. cin.tie(NULL);
  9.  
  10. string j,s;
  11. int t;
  12. cin>>t;
  13.  
  14. while(t--){
  15.  
  16. cin>>j>>s;
  17.  
  18. unordered_set<char> jewel;
  19.  
  20. for(char c : j){
  21. jewel.insert(c);
  22. }
  23.  
  24. int cnt=0;
  25. for(char c : s){
  26. if(jewel.count(c)){
  27. cnt++;
  28. }
  29. }
  30.  
  31. cout<<cnt<<'\n';
  32. }
  33. }
Success #stdin #stdout 0s 5312KB
stdin
4
abc
abcdef
aA
abAZ
aaa
a
what
none
stdout
3
2
1
0