Advertisement
askarulytarlan

В. Коровоконг решает пазл

Jan 4th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <string.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. int n,m;
  10. cin>>n>>m;
  11. string t[n];
  12.  
  13. for(int i=0;i<n;++i){
  14. cin>>t[i];
  15. }
  16. int sx=100000,sy=100000;
  17. int ex=-1, ey=-1;
  18.  
  19. for(int i=0;i<n;++i)
  20. {
  21. for(int j=0;j<m;++j)
  22. {
  23. if(t[i][j]=='X') {
  24. sx=min(sx, i);
  25. sy=min(sy, j);
  26.  
  27. ex=max(ex, i);
  28. ey=max(ey, j);
  29. }
  30. }
  31. }
  32.  
  33. bool ok=true;
  34. for(int i=sx;i<=ex;++i)
  35. {
  36. for(int j=sy;j<=ey;++j)
  37. {
  38. if(t[i][j]!='X') ok=false;
  39. }
  40. }
  41. if(ok == 0){
  42. cout << "NO";
  43. }
  44. else{
  45. cout << "YES";
  46. }
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement