daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest May 16th, 2018 119 in 2 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <algorithm>
  2. #include <deque>
  3. #include <functional>
  4. #include <iostream>
  5. #include <iterator>
  6. #include <map>
  7. #include <queue>
  8. #include <set>
  9. #include <string>
  10. #include <unordered_map>
  11. #include <unordered_set>
  12. #include <vector>
  13.  
  14. using namespace std;
  15.  
  16. #define int long long int
  17.  
  18. int32_t main() {
  19.   ios_base::sync_with_stdio(false);
  20.   cin.tie(0);
  21.  
  22.   int n;
  23.   int m;
  24.   cin >> n >> m;
  25.  
  26.   vector<string> a(n);
  27.   for (int i = 0; i < n; ++i)
  28.     cin >> a[i];
  29.  
  30.   int ceil_h = 0;
  31.   int floor_h = 0;
  32.   bool flag = 0;
  33.  
  34.   for (int i = 0; i < n; i++) {
  35.     for (int j = 0; j < m; j++)
  36.       if (a[i][j] == '*') {
  37.         if (flag == false) {
  38.           ceil_h = i;
  39.           flag = 1;
  40.         } else {
  41.           floor_h = i;
  42.         }
  43.       }
  44.   }
  45.  
  46.   int max_w = 0;
  47.   int min_w = m;
  48.  
  49.   for (int i = 0; i < n; i++) {
  50.     for (int j = 0; j < m; j++) {
  51.       if (a[i][j] == '*') {
  52.         max_w = max(max_w, j);
  53.         min_w = min(min_w, j);
  54.       }
  55.     }
  56.   }
  57.  
  58.   cout << max((max_w - min_w) + 1, (floor_h - ceil_h) + 1);
  59. }
RAW Paste Data
Top