Advertisement
rafid_shad

Plus from picture

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