行业知识
开心消消乐
#include
()#include
#include
()using namespace std;
const vector directions = {{-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {1, 0},{-1, 1}, {0, 1}, {1, 1}};
void solveMethod(int n, int m, vector& matrix)
{
int times = 0;
for (int x = 0; x
{
for (int y = 0; y
{
int cur = matrix[x][y];
if (cur == 1)
{
times++;
queue changed;
changed.push({x, y});
while (!changed.empty())
{
auto front = changed.front();
changed.pop();
for (auto& d : directions)
{
int newX = front[0] + d[0];
int newY = front[1] + d[1];
if (newX >= 0 && newX = 0 && newY
{
matrix[newX][newY] = 0;
changed.push({newX, newY});
}
}
}
}
}
}
cout n >> m;
vector matrix(n, vector(m));
for (int x = 0; x
{
for (int y = 0; y
{
cin >> matrix[x][y];
}
}
solveMethod(n, m, matrix);
return 0;
}
#include
using namespace std;
bool k[10001];
int m,n,ans=0;
int l[10001]={
0};
void search(int x,int ll){
if (l[x]>0 || !k[x]) return;
if (x==ll-1) ans++;
l[x]=ll;
int xm=x/m;
int xn=x%m;
if (xn>0) search(x-1,ll);
if (xn0){
search(x-m,ll);
if (!k[x-m]){
if (xn>0) search(x-m-1,ll);
if (xn
p cin>n>>m;for (int i=0;i>k[i];
for (int i=0;i
下一篇:惠普服务器怎么自检?