Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #include<iomanip>
- #include<algorithm>
- #include<cstdlib>
- #include<cstring>
- #include<vector>
- #include<utility>
- #define ll long long
- #define nl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(),x.end()
- #define rall(s) s.rbegin(), s.rend()
- #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
- using namespace std;
- void Fast_IO(){
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- // #ifndef ONLINE_JUDGE
- // freopen(“intersection.in”,”r”,stdin), freopen("output.txt", "w", stdout);
- // #endif
- }
- void solve(){
- ll n; cin>>n;
- ll freq_chars[26]{};
- ll freq_num[10]{};
- ll m =n;
- ll counter =0;
- while(n--){
- string s; cin>>s;
- for(int i=0; i<sz(s); i++){
- if(s[i]>='0' and s[i] <= '9'){
- freq_num[s[i]-'0']++;
- if(freq_num[s[i]-'0']>=m and n==0) counter++;
- }else if(s[i]>='a' and s[i]<='z'){
- freq_chars[s[i]-'a']++;
- if(freq_chars[s[i]-'a']>=m and n==0) counter++;
- }
- }
- }
- if(counter>0){
- cout<<counter<<nl;
- for(int i=0; i<10; i++){
- if(freq_num[i]>=m) cout<<i<<' ';
- }
- for(int i=0; i<26; i++){
- if(freq_chars[i]>=m) cout<<(char)(i+'a')<<' ';
- }
- }else cout<<"No intersect chars";
- }
- int main(){
- freopen(“intersection.in”, ”r” ,stdin);
- Fast_IO();
- int t =1;
- //cin>>t;
- while(t--){
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment