Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<string> g;
int main() {
scanf("%d %d", &n, &m);
for(int i = 0; i < n; ++i) {
string s;
cin >> s;
g.push_back(s);
}
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
if(g[i][j] == '#')
for(int k = 0; k < n; ++k)
if(g[k][j] == '#' && g[i] != g[k]) {
puts("No");
return 0;
}
cout << "Yes" << endl;
return 0;
}
Copy The Code &
Try With Live Editor
Input
5 8
.#.#..#.
.....#..
.#.#..#.
#.#....#
.....#..
.#.#..#.
.....#..
.#.#..#.
#.#....#
.....#..
Output
yes
Demonstration
Codeforces Solution-Mystical Mosaic-Solution in C, C++, Java, Python