Advertisement
JouJoy

Untitled

Dec 20th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6.  
  7. void solve(){
  8.  
  9. int n,m;
  10. cin>>n>>m;
  11.  
  12. vector<string>s(n);
  13.  
  14. int tot=0;
  15.  
  16. for(int i=0 ; i<n ; i++){
  17. cin>>s[i];
  18. for(int j=0 ; j<m ; j++) tot += s[i][j] == '*';
  19. }
  20.  
  21. for(int i=0 ; i<n ; i++){
  22. for(int j=0 ; j<m ; j++){
  23. if(s[i][j]=='*'){
  24.  
  25. int cnt = 1;
  26. int c = 0;
  27. int k;
  28. for(k=i+1 ; k<n&&s[k][j]=='*' ; k++) c++;
  29. if(!c) continue;
  30. cnt += c;
  31.  
  32. c=0;
  33. for(k=i-1 ; k>=0&&s[k][j]=='*' ; k--) c++;
  34. if(!c) continue;
  35. cnt += c;
  36.  
  37. c=0;
  38. for(k=j+1 ; k<m&&s[i][k]=='*' ; k++) c++;
  39. if(!c) continue;
  40. cnt += c;
  41.  
  42. c=0;
  43. for(k=j-1 ; k>=0&&s[i][k]=='*' ; k--) c++;
  44. if(!c) continue;
  45. cnt += c;
  46.  
  47. if(cnt==tot){
  48. cout<<"YES\n";
  49. return;
  50. }
  51. }
  52. }
  53. }
  54.  
  55. cout<<"NO\n";
  56.  
  57. }
  58. int main(){
  59.  
  60. int tc=1;
  61. //cin>>tc;
  62. while(tc--){
  63. solve();
  64. }
  65.  
  66. }
  67.  
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement