世界名画陈列馆问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 17:32:28
用代码实现
世界名画陈列馆由m×n个陈列室组成。为了防止名画被盗,需在陈列室中设置警卫机器人哨位。每个警卫机器人除监视它所在的陈列室为,还可以监视与它所在陈列室相邻的上、下、左、右4个陈列室。试设计一个安排警卫机器人哨位的算法,使得名画陈列馆中每个陈列室都在警卫机器人监视之下,且所用的警卫机器人数最少
谁知道怎么做吗

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
class Program
{
static int[,] d = { {0,0,0}, {0,0,0}, {0,0,-1}, {0,-1,0}, {0,0,1}, {0,1,0} };
static int[,] x = new int[100, 100];
static int[,] y = new int[100, 100];
static int[,] bestx = new int[100, 100];
static int n, m, best, k = 0, t = 0;
static int t1, t2, more;

static void change(int i, int j)
{
x[i, j] = 1;
k++;
for (int r = 1; r <= 5; r++)
{
int p = i + d[r, 1];
int q = j + d[r, 2];
y[p, q]++;
if (y[p, q] == 1)
t++;
}
}

static void restore(int i, int j)
{