Created
February 3, 2017 21:55
-
-
Save KhaledElshamy/fae4e8d93ff7f54bbda89ef76dba2bef to your computer and use it in GitHub Desktop.
B. President's Office-Codeforces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// working.cpp by Bill Weinman <http://bw.org/> | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int n,m,check[27]={0},res=0; | |
char c,a[150][150]; | |
cin>>n>>m>>c; | |
for(int i=0;i<n;i++) | |
for(int j=0;j<m;j++) | |
cin>>a[i][j]; | |
for(int i=0;i<n;i++) | |
for(int j=0;j<m;j++) | |
if(a[i][j]==c) | |
check[a[i-1][j]-'A']=check[a[i+1][j]-'A']=check[a[i][j-1]-'A']=check[a[i][j+1]-'A']=1; | |
for(int i=0;i<=26;i++) res+=check[i]; | |
cout<<res-check[c-'A']<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment