摆桶问题

条件的算法描述如下:
Given integer m and n where n is odd, for all mxn matrixes that consist of 0 and 1, find the one that has max count of 1s and meets following conditions:

  1. All 0s are connected;
  2. All 1s are adjacent to at least one 0 (Adjacent includes diagonal line adjacent, 8 directions);
  3. maxtrix[m-1][n/2] = 0.

Example :

Input: m=2, n=3
Output: [[1,1,1],[1,0,1]]

Follow up:
Given another list of ‘blocked’ points. Matrix will set those points to -1 and you cannot change that. Solve the problem again.

目前所得结果:
Max=135
如果有更高级解法,请指教~
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值