Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <queue>
  5. #include <map>
  6. #include <set>
  7. #include <cmath>
  8. //#include<bits/stdc++.h>
  9. //#define int long long
  10. #define pb push_back
  11. using namespace std;
  12. bool isInt(char a)
  13. {
  14.     for(int i = 0; i < 10; i++)
  15.         if(a - '0' == i)
  16.             return true;
  17.     return false;
  18. }
  19. signed main()
  20. {
  21.     int t;
  22.     cin >> t;
  23.     map<int,int> schools;
  24.     for(int i = 0; i <= t; i++)
  25.     {
  26.         string s,str;
  27.         getline(cin,s);
  28.         for(int j = 0; j < s.length(); j++)
  29.         {
  30.             bool f = false;
  31.             while(isInt(s[j]))
  32.             {
  33.                 str += s[j];
  34.                 f = true;
  35.                 j++;
  36.             }
  37.             if(f)
  38.                 j = s.length()+1;
  39.         }
  40.         if(str.length() > 0 && schools.find(stoi(str)) == schools.end())
  41.             schools.emplace(stoi(str),1);
  42.         else if(str.length() > 0 && schools.find(stoi(str)) != schools.end())
  43.         {
  44.             auto it = schools.find(stoi(str));
  45.             it->second++;
  46.         }
  47.     }
  48.     vector<int> ans;
  49.     for(auto i: schools)
  50.         if(i.second <= 5)
  51.             ans.pb(i.first);
  52.     cout << ans.size() << "\n";
  53.     for(auto i: ans)
  54.         cout << i << "\n";
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement