zoukankan      html  css  js  c++  java
  • [攻防世界

    打开exe后发现不需要上ida,直接玩游戏即可

    相当于一个初始全为0的长度为8的数组,每次操作选一个位置,将其与其相邻共3个数取反(首尾相邻,可看做一个环),一直操作到全部为1。易知最优解的按键上限为8次,在最优解中不会重复按键。
    直接用c++写出搜索脚本

    // rg是register,print是自定义的输出
    stack<int> s;
    bool lamp[10], inS[10];
    int ans[10];
    inline void get()
    {
    	rg int siz = s.size();
    	for (rg int i = siz; i >= 1; --i) ans[i] = s.top(), s.pop();
    	for (rg int i = 1; i <= siz; ++i) print(ans[i]);
    }
    inline int change(int now, int tota)
    {
    	rg int upper = now - 1, lower = now + 1;
    	if (upper == 0) upper = 8;
    	if (lower == 9) lower = 1;
    	
    	if (!lamp[upper]) ++tota;
    	else --tota;
    	if (!lamp[now]) ++tota;
    	else --tota;
    	if (!lamp[lower]) ++tota;
    	else --tota;
    	lamp[upper] ^= 1;
    	lamp[now] ^= 1;
    	lamp[lower] ^= 1;
    	return tota;
    }
    inline void bfs(int tot, int j)
    {
    	if (tot == 8)
    	{
    		get();
    		exit(0);
    	}
    	for (rg int i = 1; i <= 8; ++i)
    	{
    		if (inS[i]) continue;
    		inS[i] = true, s.push(i), bfs(change(i, tot), i), s.pop();
    		change(i, tot), inS[i] = false;
    	}
    }
    int main()
    {
    	for (rg int i = 1; i <= 8; ++i) lamp[i] = 0;
    	bfs(0, 0);
    	return 0;
    }
    

    发现按顺序输入12345678即可

    得到flag:

    zsctf{T9is_tOpic_1s_v5ry_int7resting_b6t_others_are_n0t}
    
  • 相关阅读:
    关于 省赛模拟赛(迪迦桑专场)
    ZOJ3878: Convert QWERTY to Dvorak(浙江省赛2015)
    Is It A Tree?
    Escape
    关于细节
    [UE4]AnimDynamics简介
    [UE4]武器碰撞
    [UE4]CustomAnimationBlueprintNode 自定义动画蓝图节点
    百钱买白鸡
    asp.net 标准控件的重要属性
  • 原文地址:https://www.cnblogs.com/Here-is-SG/p/15201702.html
Copyright © 2011-2022 走看看