Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <string.h>
- using namespace std;
- int main() {
- int n,m;
- cin>>n>>m;
- string t[n];
- for(int i=0;i<n;++i){
- cin>>t[i];
- }
- int sx=100000,sy=100000;
- int ex=-1, ey=-1;
- for(int i=0;i<n;++i)
- {
- for(int j=0;j<m;++j)
- {
- if(t[i][j]=='X') {
- sx=min(sx, i);
- sy=min(sy, j);
- ex=max(ex, i);
- ey=max(ey, j);
- }
- }
- }
- bool ok=true;
- for(int i=sx;i<=ex;++i)
- {
- for(int j=sy;j<=ey;++j)
- {
- if(t[i][j]!='X') ok=false;
- }
- }
- if(ok == 0){
- cout << "NO";
- }
- else{
- cout << "YES";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement