Ahmed_Negm

Untitled

Apr 22nd, 2022
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<iomanip>
  4. #include<algorithm>
  5. #include<cstdlib>
  6. #include<cstring>
  7. #include<vector>
  8. #include<utility>
  9.  
  10. #define ll long long
  11. #define nl '\n'
  12. #define sz(x) int(x.size())
  13. #define all(x) x.begin(),x.end()
  14. #define rall(s)  s.rbegin(), s.rend()
  15. #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  16. using namespace std;
  17.  
  18. void Fast_IO(){
  19.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  20. //     #ifndef ONLINE_JUDGE
  21. //         freopen(“intersection.in”,”r”,stdin), freopen("output.txt", "w", stdout);
  22. //     #endif
  23. }
  24.  
  25.  
  26.  
  27.  
  28.  
  29. void solve(){
  30.   ll n; cin>>n;
  31.   ll freq_chars[26]{};
  32.   ll freq_num[10]{};
  33.   ll m =n;
  34.       ll counter =0;
  35.   while(n--){
  36.       string s; cin>>s;
  37.       for(int i=0; i<sz(s); i++){
  38.           if(s[i]>='0' and s[i] <= '9'){
  39.               freq_num[s[i]-'0']++;
  40.               if(freq_num[s[i]-'0']>=m and n==0) counter++;
  41.           }else if(s[i]>='a' and s[i]<='z'){
  42.               freq_chars[s[i]-'a']++;
  43.               if(freq_chars[s[i]-'a']>=m and n==0) counter++;
  44.           }
  45.       }
  46.  
  47.   }
  48.  
  49.   if(counter>0){
  50.       cout<<counter<<nl;
  51.       for(int i=0; i<10; i++){
  52.           if(freq_num[i]>=m) cout<<i<<' ';
  53.       }
  54.       for(int i=0; i<26; i++){
  55.           if(freq_chars[i]>=m) cout<<(char)(i+'a')<<' ';
  56.       }
  57.   }else cout<<"No intersect chars";
  58.  
  59.  
  60.  
  61.  
  62. }
  63.  
  64. int main(){
  65.     freopen(“intersection.in”, ”r” ,stdin);
  66.     Fast_IO();
  67. int t =1;
  68. //cin>>t;
  69. while(t--){
  70. solve();
  71. }
  72. return 0;
  73. }  
Advertisement
Add Comment
Please, Sign In to add comment