Advertisement
rafid_shad

B

Jul 29th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.14 KB | None | 0 0
  1.  
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. //*****************Data type**********************//
  6. typedef long long ll;
  7. typedef long long int lli;
  8. typedef unsigned long long  ull;
  9. typedef unsigned long long int ulli;
  10.  
  11. //*****************Map****************************//
  12. typedef map<int, int> mp;
  13. typedef map<int, string> mps;
  14. typedef map<int, char>mpc;
  15. typedef map<string, int>mpsi;
  16. typedef map<char, int>mpci;
  17.  
  18. //****************Pair****************************//
  19. typedef pair<int, int> pii;
  20. typedef pair<string, string> pss;
  21. typedef pair<char, char> pcc;
  22. typedef pair<int, string> pis;
  23. typedef pair<int, char> pic;
  24.  
  25. //*****************Vector************************//
  26. typedef vector<int> VI;
  27. typedef vector<string> VS;
  28. typedef vector<double> VD;
  29. typedef vector<lli> VLLI;
  30. typedef vector<VI> VVI;
  31. typedef vector<pii> VPI;
  32.  
  33. //-------------------------------------------------------------------------------//
  34. #define pp1(A)              printf("%d\n",A)
  35. #define pp2(A,B)            printf("%d %d\n",A,B)
  36. #define pp3(A,B,C)          printf("%d %d %d\n",A,B,C)
  37.  
  38. #define ss1(A)              scanf("%d", &A)
  39. #define ssl(A)              scanf("%lld", &A)
  40. #define ss2(A,B)            scanf("%d,%d",&A,&B)
  41. #define ss3(A,B,C)          scanf("%d,%d,%d",&A,&B,&C)
  42.  
  43. //--------------------------------------------------------------------------------//
  44. #define nosync              ios_base::sync_with_stdio(false), cin.tie(NULL)
  45. #define pf                  push_front
  46. #define pb                  push_back
  47. #define popp                pop_back()
  48. #define itr                 iterator
  49. #define mk                  make_pair
  50. #define ff                  first
  51. #define ss                  second
  52. #define END                 return 0
  53. #define line                printf("\n")
  54. #define sq(a)               (a)*(a)
  55. #define SZ(a)               (int)a.size()
  56. #define all(a)              (a).begin(), (a).end()
  57. #define Erase(V,I)          (V).erase((V).begin()+I)
  58. #define Insert(V,I,M)       (V).insert((V).begin()+I,M)
  59.  
  60. //********************************************************************************//
  61. #define loop(i,n)           for(int i=0;i<n;i++)
  62. #define loop2(i,n)          for(int i=n-1;i>=0;i--)
  63. #define loop3(i,t)          for(int i=1;i<=t;i++)
  64. #define scanV(V, N)         for(int i=0; i<N; i++){ int X; ss1(X); V.pb(X); }
  65. #define scanVll(V, N)       for(int i=0; i<N; i++){ lli X; ssl(X); V.pb(X); }
  66. #define scanA(A, N)         for(int i=0; i<N; i++){ ss1(A[i]); }
  67. #define printA(A, N)        for(int i=0; i<N; i++){ cout<<A[i]<<" "; }
  68. #define printAL(A, N)       for(int i=0; i<N; i++){ cout<<A[i]<<endl; }
  69. #define printV(V, N)        for(int i=0; i<N; i++){ cout<<V[i]<<endl; }
  70. #define vout(v)             for(int i=0;i<v.size();i++){ cout<<v[i]; if(i<v.size()-1) cout<<" "; else cout<<endl;}
  71. #define voutll(V)           for(int i=0; i<V.size(); i++){ cout<<V[i]<<" "; }
  72.  
  73. /*-----------------------GCD && LCM------------------*/
  74. int gcd(int a, int b) {  return b == 0 ? a : gcd(b , a % b); }
  75. int lcm(int a, int b) {  return a * (b / gcd(a, b)); }
  76. /*---------------------------------------------------*/
  77.  
  78. //---------------------------------*START*-----------------------------------------//
  79.  
  80. int main()
  81. {
  82.    int n,m;
  83.    cin>>n>>m;
  84.    string s[n];
  85.    loop(i,n)
  86.    {
  87.        cin>>s[i];
  88.    }
  89.    int count=0;
  90.    loop(i,n)
  91.    {
  92.        loop(j,m)
  93.        {
  94.            if(s[i][j]=='*')
  95.            {
  96.                count++;
  97.            }
  98.        }
  99.    }
  100.    for(int i=1;i<n-1;i++)
  101.    {
  102.  
  103.        for(int j=1;j<m;j++)
  104.        {
  105.            if(s[i][j]=='.')
  106.            {
  107.                continue;
  108.            }
  109.  
  110.            if(s[i-1][j]=='*' and s[i+1][j]=='*' and s[i][j-1]=='*' and s[i][j+1]=='*')
  111.            {
  112.                count=count-1;
  113.                for(int k=i-1;k>=0;k--)
  114.                {
  115.                    if(s[k][j]=='*')
  116.                    {
  117.                        count--;
  118.                    }
  119.                    else
  120.                    {
  121.                        break;
  122.                    }
  123.                }
  124.                for(int k=i+1;k<n;k++)
  125.                {
  126.                    if(s[k][j]=='*')
  127.                    {
  128.                        count--;
  129.                    }
  130.                    else
  131.                    {
  132.                        break;
  133.                    }
  134.                }
  135.                 for(int k=j-1;k>=0;k--)
  136.                {
  137.                    if(s[i][k]=='*')
  138.                    {
  139.                        count--;
  140.                    }
  141.                    else
  142.                    {
  143.                        break;
  144.                    }
  145.                }
  146.                for(int k=j+1;k<m;k++)
  147.                {
  148.                    if(s[i][k]=='*')
  149.                    {
  150.                        count--;
  151.                    }
  152.                    else
  153.                    {
  154.                        break;
  155.                    }
  156.                }
  157.                if(count==0)
  158.                {
  159.                    cout<<"YES"<<endl;
  160.                }
  161.                else
  162.                {
  163.                    cout<<"NO"<<endl;
  164.                }
  165.                END;
  166.            }
  167.        }
  168.    }
  169.    cout<<"NO"<<endl;
  170.    END;
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement