fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  5. #define ll long long
  6. #define rep(i, a, b) for (int i = (a); i < (b); ++i)
  7. #define repr(i, a, b) for (int i = (a); i > (b); --i)
  8.  
  9. void solve() {
  10. ll n, m;
  11. cin >> n >> m;
  12. vector<string> a(n);
  13.  
  14. rep(i, 0, n) {
  15. cin >> a[i];
  16. }
  17.  
  18. ll b[m];
  19. memset(b, -1, sizeof(b));
  20.  
  21. ll ans = 0;
  22. set<int>st;
  23. rep(i, 0, n) {
  24. string x = a[i];
  25.  
  26. for (int j = 0; j < m; j++) {
  27. if(x[j]=='?'){
  28. continue;
  29. }
  30. if(b[j]==-1){
  31. b[j] = x[j] - 'a';
  32. }else{
  33. if(b[j]!=x[j]-'a' && !st.count(j)){
  34. ans++;
  35. st.insert(j);
  36. }
  37. }
  38. }
  39. }
  40.  
  41. cout << ans << endl;
  42. }
  43.  
  44. int main() {
  45. fastio;
  46. solve();
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
0