giabinh

P142PROH_DanKien

Nov 25th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define fto(i, l, r) for (int i=l; i<=r; ++i)
  4.  
  5. using namespace std;
  6.  
  7. int r, c, ans = 0;
  8. char a[11][11];
  9. bool ate[11][11];
  10.  
  11. int main() {
  12.     #ifndef ONLINE_JUDGE
  13.         freopen("P142PROH.inp", "r", stdin);
  14.     #endif // ONLINE_JUDGE
  15.  
  16.     scanf("%d%d", &r, &c);
  17.     fto(i, 0, r - 1)
  18.     {
  19.         fto(j, 0, c - 1) scanf("%c", &a[i][j]);
  20.         char tmp; scanf("%c", &tmp);
  21.     }
  22.  
  23.     memset(ate, false, sizeof ate);
  24.     fto(i, 0, r - 1)
  25.     {
  26.         bool found = false;
  27.         fto(j, 0, c - 1)
  28.             if (a[i][j] == 'S')
  29.             {
  30.                 found = true;
  31.                 break;
  32.             }
  33.  
  34.         if (!found)
  35.         {
  36.             ans += c;
  37.             fto(j, 0, c - 1) ate[i][j] = true;
  38.         }
  39.     }
  40.  
  41.     fto(j, 0, c - 1)
  42.     {
  43.         bool found = false;
  44.         fto(i, 0, r - 1)
  45.             if (a[i][j] == 'S')
  46.             {
  47.                 found = true;
  48.                 break;
  49.             }
  50.  
  51.         if (!found)
  52.             fto(i, 0, r - 1)
  53.                 if (!ate[i][j]) ++ans;
  54.     }
  55.  
  56.     printf("%d", ans);
  57.  
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment