Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <queue>
- #include <map>
- #include <set>
- #include <cmath>
- //#include<bits/stdc++.h>
- //#define int long long
- #define pb push_back
- using namespace std;
- bool isInt(char a)
- {
- for(int i = 0; i < 10; i++)
- if(a - '0' == i)
- return true;
- return false;
- }
- signed main()
- {
- int t;
- cin >> t;
- map<int,int> schools;
- for(int i = 0; i <= t; i++)
- {
- string s,str;
- getline(cin,s);
- for(int j = 0; j < s.length(); j++)
- {
- bool f = false;
- while(isInt(s[j]))
- {
- str += s[j];
- f = true;
- j++;
- }
- if(f)
- j = s.length()+1;
- }
- if(str.length() > 0 && schools.find(stoi(str)) == schools.end())
- schools.emplace(stoi(str),1);
- else if(str.length() > 0 && schools.find(stoi(str)) != schools.end())
- {
- auto it = schools.find(stoi(str));
- it->second++;
- }
- }
- vector<int> ans;
- for(auto i: schools)
- if(i.second <= 5)
- ans.pb(i.first);
- cout << ans.size() << "\n";
- for(auto i: ans)
- cout << i << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement