Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 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.     vector<string> schools,ans;
  24.     while(t--)
  25.     {
  26.         string s;
  27.         string str="";
  28.         getline(cin,s);
  29.         for(auto i: s)
  30.             if(isInt(i))
  31.                 str+=i;
  32.         schools.pb(str);
  33.     }
  34.     int cnt = 1;
  35.     sort(schools.begin(),schools.end());
  36.     for(int i = 1; i < schools.size(); i++)
  37.     {
  38.         if(schools[i-1] == schools[i])
  39.             cnt++;
  40.         else
  41.         {
  42.             if(cnt <= 5)
  43.                 ans.pb(schools[i-1]);
  44.             cnt = 1;
  45.         }
  46.     }
  47.     cout << ans.size() << "\n";
  48.     for(auto i: ans)
  49.         cout << i << "\n";
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement