fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. bool check(vector<int> &arr1,vector<int> &arr2, unordered_map<int,int> &mp)
  4. {
  5. for(auto &i: arr2)
  6. {
  7. cin>>i;
  8. if(mp[i]==0)
  9. {
  10. return false;
  11. }
  12. else
  13. {
  14. mp[i]--;
  15. }
  16. }
  17. return true;
  18. }
  19. int main()
  20. {
  21. int n1,n2;
  22. cin>>n1>>n2;
  23. unordered_map<int,int> mp;
  24. vector<int> arr1(n1);
  25. vector<int> arr2(n2);
  26. for(auto &i: arr1)
  27. {
  28. cin>>i;
  29. mp[i]++;
  30. }
  31. bool d=check(arr1,arr2,mp);
  32. if(d)
  33. {
  34. cout<<"is a subset";
  35. }
  36. else
  37. {
  38. cout<<"not a subset";
  39. }
  40.  
  41.  
  42.  
  43.  
  44. }
Success #stdin #stdout 0.38s 65104KB
stdin
Standard input is empty
stdout
is a subset