AmoebaDivTwo
#include <string>
#include <vector>
using namespace std;
class AmoebaDivTwo{public:
int count( vector <string> table, int K )
{
int w = (int)table[0].size();
int h = (int)table.size();
int ans = 0;
for ( int y=0; y<h; y++ )
for ( int x=0; x+K<=w; x++ )
{
bool f = true;
for ( int i=0; i<K; i++ )
if ( table[y][x+i] == 'M' )
f = false;
if ( f )
ans++;
}
if ( K >= 2 )
for ( int y=0; y+K<=h; y++ )
for ( int x=0; x<w; x++ )
{
bool f = true;
for ( int i=0; i<K; i++ )
if ( table[y+i][x] == 'M' )
f = false;
if ( f )
ans++;
}
return ans;
}};