Advertisement
ccbeginner

TIOJ 2154

Oct 24th, 2020
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <time.h>
  3. using namespace std;
  4. #define SZ(x) (int)(x.size())
  5. #define int long long
  6.  
  7. bool cnt[26], aux[26];
  8.  
  9. int32_t main(){
  10.     srand(time(0));
  11.     int n;
  12.     cin >> n;
  13.     string s;
  14.     cin >> s;
  15.     for(int i = 0; i < SZ(s); ++i)cnt[s[i]-'a'] = 1;
  16.     for(int i = 1; i < n; ++i){
  17.         cin >> s;
  18.         memset(aux, 0, sizeof(aux));
  19.         for(int j = 0; j < SZ(s); ++j){
  20.             aux[s[j]-'a'] = 1;
  21.         }
  22.         for(int j = 0; j < 26; ++j){
  23.             cnt[j] &= aux[j];
  24.         }
  25.     }
  26.     int ans = 7122;
  27.     for(int i = 0; i < 26 && ans == 7122; ++i){
  28.         if(cnt[i] == 1)ans = i;
  29.     }
  30.     if(ans == 7122)cout << ans << '\n';
  31.     else cout << char(ans + 'a') << '\n';
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement