SHARE
TWEET

codeforce - little pigs and wolves

jakaria_hossain Jun 27th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  5. int main()
  6. {
  7.     fast();
  8.     int m,n,cnt=0;
  9.     cin>>n>>m;
  10.     char ara[n+1][m+1];
  11.     for(int i=0;i<n;i++)
  12.     {
  13.         for(int j=0;j<m;j++)cin>>ara[i][j];
  14.     }
  15.     for(int i=0;i<n;i++)
  16.     {
  17.         for(int j=0;j<m;j++)
  18.         {
  19.             if(ara[i][j]=='W')
  20.             {
  21.                 if (ara[i-1][j] == 'P' || ara[i+1][j] == 'P' || ara[i][j-1] == 'P' || ara[i][j+1] == 'P')cnt++;
  22.             }
  23.         }
  24.     }
  25.     cout<<cnt<<endl;
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top