摘要:
代码如下:#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>#define TO(x, y) (x-1)*N+yusing namespace std;char G[30][30];int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1}, N;int C;inline bool judge(int x, int y){ if (x < 1 || x > N || y < 1 || y > N) { 阅读全文
posted @ 2012-07-26 22:56
沐阳
阅读(315)
评论(0)
推荐(0)
摘要:
这题我们可以参考开关那题,只不过这里是求最少的操作次数,那么我们需要对变元进行枚举,算出所有的情况下,最少需要改变的次数。代码如下:#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>#define TO(x, y) (x-1)*4+yusing namespace std;char G[6][6];int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};inline bool judge(int x, int y){ if 阅读全文
posted @ 2012-07-26 22:06
沐阳
阅读(403)
评论(0)
推荐(0)
摘要:
这题是给定N个灯的初始和最终状态,再给定一些关系,这些关系说明按某个开关可能影响其他的灯的开关情况,可以将这种关系视为一种取反的关系。对于这题我们假设一组数据:30 1 01 1 01 22 31 33 20 0对于以上的数据,我们用矩阵来表示整个操作的过程和状态 0 1S = 1 E = 1 0 0我们可以很显然的知道,某个等的亮灭情况将体现出各个开关的复合结果,因此我们可以得到这样的方程组,模二加等价于异或操作:E(a) = xa*A11 ^ xb*A12 ^ xc*A13 ^ S(a);E(b) = xa*A21 ^ xb*A22 ... 阅读全文
posted @ 2012-07-26 02:19
沐阳
阅读(1346)
评论(1)
推荐(0)


浙公网安备 33010602011771号