Created
August 1, 2019 08:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
char mat[50][50]; | |
bool row[50]; | |
bool col[50]; | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
int n, m; | |
cin >> n >> m; | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < m; j++) { | |
cin >> mat[i][j]; | |
if (mat[i][j] == 'X') { | |
row[i] = col[j] = true; | |
} | |
} | |
} | |
int ans = 0; | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < m; j++) { | |
if (!row[i] && !col[j]) { | |
ans += 1; | |
row[i] = col[j] = true; | |
} | |
} | |
} | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < m; j++) { | |
if (!row[i] || !col[j]) { | |
ans += 1; | |
row[i] = col[j] = true; | |
} | |
} | |
} | |
cout << ans << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment