其他分享
首页 > 其他分享> > 复现

复现

作者:互联网

KCTF 第二题 南冥神功


硬看,发现通关要求是把aS_1全搞成1

然后这里是在aS_1数组里的移动,像是二维平面八方向走一样
有个很智障的地方就是aS_1的起始数值是这个'S'不是0……直接跳过结果搜不出路径


只能走到为0的位置,走过之后就置为1,也就是一笔画路径

搜了一下果然只有一条符合要求的路径,然后根据方向输出每一次case的选项

a=[1,0,1,0,0,1,0,0,1,1,
   1,1,0,0,1,0,0,1,0,0,
   0,0,1,0,1,1,1,1,1,0,
   0,1,1,0,1,0,0,1,0,0,
   0,0,1,0,0,1,0,0,1,1,
   1,1,0,1,1,1,0,1,0,1,
   0,0,1,1,1,1,0,1,0,1,
   0,1,1,0,0,1,0,1,0,1,
   0,0,0,1,0,0,1,1,0,0]
dj=[[-1,0],[0,1],[1,0],[1,-1],[0,-1],[-1,-1]]
du=[[-1,1],[0,1],[+1,+1],[1,0],[0,-1],[-1,0]]
v=150*[0]
s=150*[0]
top=0

def dfs(w,x,y):
    # print(w,x,y)
    global top
    if w==46:
        print(x,y)
        for i in range(46):
            print("%d,"%s[i],end='')
        return
    if x&1:
        for i in range(6):
            if x+dj[i][0]>=0 and x+dj[i][0]<9 and y+dj[i][1]>=0 and y+dj[i][1]<10 and a[(x+dj[i][0])*10+y+dj[i][1]]==0 and v[(x+dj[i][0])*10+y+dj[i][1]]==0:
                v[(x+dj[i][0])*10+y+dj[i][1]]=1
                s[top]=i
                top+=1
                dfs(w+1,x+dj[i][0],y+dj[i][1])
                v[(x+dj[i][0])*10+y+dj[i][1]]=0
                top-=1
    else:
        for i in range(6):
            if x+du[i][0]>=0 and x+du[i][0]<9 and y+du[i][1]>=0 and y+du[i][1]<10 and a[(x+du[i][0])*10+y+du[i][1]]==0 and v[(x+du[i][0])*10+y+du[i][1]]==0:
                v[(x+du[i][0])*10+y+du[i][1]]=1
                s[top]=i
                top+=1
                dfs(w+1,x+du[i][0],y+du[i][1])
                v[(x+du[i][0])*10+y+du[i][1]]=0
                top-=1

if __name__=='__main__':
    # print(a.count(0))
    print(a.count(0))
    v[0]=1
    dfs(0,0,0)
#1,2,3,4,3,2,1,2,3,4,3,2,1,1,0,1,2,1,0,0,5,0,5,4,3,4,5,0,5,0,1,2,1,0,1,2,1,2,3,4,3,2,2,3,2,1,

然后一个flag字符对应走两步,加上这两次的约束条件发现每个flag位置符合要求的字符唯一
脚本:

a=[1,2,3,4,3,2,1,2,3,4,3,2,1,1,0,1,2,1,0,0,5,0,5,4,3,4,5,0,5,0,1,2,1,0,1,2,1,2,3,4,3,2,2,3,2,1]
d='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(0,len(a),2):
    for j in range(len(d)):
        if (i//2+j)%6==5-a[i] and (i//2+j//6)%6==a[i+1]:
            print(d[j],end='')
#GJ0V4LA4VKEVQZSVCNGJ00N

标签:150,dj,range,复现,print,end,du
来源: https://www.cnblogs.com/diakla/p/15130894.html