跳到正文

anmengxun

793142

落花雨潇潇,伊人独思绍。白马策平羌,公子何不回首唱?

在洛谷打开
资料、奖项与版本

资料

编号
793142
抓取

奖项

2024 CSP-S
一等奖
2024 NOIP
一等奖
2023 CSP-S
二等奖
2023 NOIP
二等奖

2022/9/11 重拾OI

2023/5/15 100AC,by B3761 三角魔方,亦第一道绿题这你也要记。

2023/7/19 第一道蓝题AC,byP3919 可持久化线段树1这你也要记。

2023/7/24 第一道紫题AC,byP5494 线段树分裂怎么全是模板题啊

2023/9/2 200AC,byP2820 局域网

2023/11/6 300AC,byP4933 大师

2023/11/13 橙名祭

2024/10/9 400AC,byP3017 Brownie Slicing G

2024/10/16 第一道完全独立完成的紫题,byP11189 水杯降温好耶!!!

2024/11/13 100绿题AC,byP4290 玩具取名

2024/11/18 再度橙名

2024/11/30 NOIp2024

2024/12/2 红名祭!

2024/12/23 AFO

世界未解之谜

玩过一加一吗?

C++
/*
  用于生成解答树,输出类型为文件输出,输出文件名为“Ans-Tree.txt”。
  使用方法:
  输入某个情况下的节点编号和需求的解答子树高度(一般为3就合适),其输出以该节点为根,相应高度的子树。
  范例:
  输入:1 3
  输出:
  1  2     
  1  1     
  1  2     
  1  3     
  
  2  2     2  4     1  3     1  5     
  1  3     1  3     1  3     1  3     
  2  2     2  4     1  3     1  5     
  1  5     3  3     1  6     1  4     
  
  2  3     2  7     2  3     2  7     4  5     4  5     2  7     2  7     2  3     3  7     1  4     1  9     2  5     5  5     1  6     1  9     
  1  5     1  5     1  5     1  5     3  3     3  3     3  3     3  3     1  6     1  6     1  6     1  6     1  4     1  4     1  4     1  4     
  2  3     2  7     2  3     2  7     4  5     4  5     2  7     2  7     2  3     3  7     1  4     1  9     2  5     5  5     1  6     1  9     
  1  8     1  X     1  8     1  X     3  8     3  8     3  X     3  X     1  8     1  X     1  X     1  X     3  4     4  6     1  X     1  X     
  
  (3)      (32)     (40)     (69)     (78)     (89)     (100)    (106)    (113)    (142)    (149)    (159)    (165)    (196)    (207)    (218)    
  
  其中叶节点下面的括号代表其节点编号,依次可以继续查询。
  
  另外,目前并不支持直接查询除原始状态(指敌方 1 2,我方1 1的状态,是根节点,节点编号为1)之外的状态,除非你清楚它的节点编号。你只能从根节点开始向下寻找,这要求你清楚你们每一步是怎么走的。

 */
#include <iostream>//2023.5.6 18:26 首次计算出后手必胜 //2023.5.6 19:20 制作出后手交互版 //2023.9.24 23:19 制作出可读性优秀的生成解答树版并完成了正确性检验
#include <stdio.h>
#include <vector>
using namespace std;
vector <int> this_v,next_v;
int num[4] = {1,1,1,1},bigcon = 0,step = 1;
string line1,line2,line3,line4,line5;
struct memory{
	int b[10][10];
}a[10][10];
bool win(int act)
{
	return num[act] >= 10 && num[act + 1] >= 10;
}
int af,as,bf,bs;
void dic(int act)
{
	if (num[act] <= num[act + 1])
	{
		af = num[act];
		as = num[act + 1];
	}
	else
	{
		af = num[act + 1];
		as = num[act];
	}
	if (num[2 - act] <= num[2 - act + 1])
	{
		bf = num[2 - act];
		bs = num[2 - act + 1];
	}
	else
	{
		bf = num[2 - act + 1];
		bs = num[2 - act];
	}
}
int recall(int act)
{
	dic(act);
	return a[af][as].b[bf][bs];
}
void write(int act,int k)
{
	dic(act);
	a[af][as].b[bf][bs] = k;
}
void dfs(int action)
{
	if (recall(action) == 1)
	{
		return;
	}
	if (recall(action) == -1)
	{
		bigcon = 1;
		return;
	}
	for (int i = action;i <= action + 1;i++)
	{
		if (num[i] < 10)
		{
			for (int j = (2 - action);j <= (2 - action + 1);j++)
			{
				if (num[j] < 10)
				{
					num[i] += num[j];
					if (win(action))
					{
						num[i] -= num[j];
						return;
					}
					step++;
					dfs(2 - action);
					step--;
					num[i] -= num[j];
					if (bigcon)
					{
						if (step == 2)
						{
							bigcon++;
						}
						bigcon--;
						write(action,1);
						return;
					}
				}
			}
		}
	}
	bigcon = 1;
	write(action,-1);
	return;
}
int s1,s2,s3,s4;
void ans()
{
	for (int i = 2;i <= 3;i++)
	{
		if (num[i] < 10)
		{
			for (int j = 0;j <= 1;j++)
			{
				if (num[j] < 10)
				{
					num[i] += num[j];
					if (recall(0) == -1)
					{
						s1 = min(num[0],num[1]),s2 = max(num[0],num[1]),s3 = min(num[2],num[3]),s4 = max(num[2],num[3]);
						return;
					}
					num[i] -= num[j];
				}
			}
		}
	}
	s1 = 10,s2 = 10,s3 = 10,s4 = 10;
	return;
}
struct Ans_Tree{
	int son[4];
	int situ[4];
	int solve[4];
}ans_tree[20 * 20 * 20 *20];
int pos = 1;
void make_tree(int now,int n1,int n2,int n3,int n4)
{
	ans_tree[now].situ[0] = num[0] = n1,ans_tree[now].situ[1] = num[1] = n2,ans_tree[now].situ[2] = num[2] = n3,ans_tree[now].situ[3] = num[3] = n4;
	ans();
	ans_tree[now].solve[0] = s1,ans_tree[now].solve[1] = s2,ans_tree[now].solve[2] = s3,ans_tree[now].solve[3] = s4;
	int sons = 0;
	for (int i = 0;i <= 1;i++)
	{
		if (ans_tree[now].solve[i] < 10)
		{
			for (int j = 2;j <= 3;j++)
			{
				if (ans_tree[now].solve[j] < 10)
				{
					ans_tree[now].solve[i] += ans_tree[now].solve[j];
					ans_tree[now].son[sons++] = ++pos;
					make_tree(pos,min(ans_tree[now].solve[0],ans_tree[now].solve[1]),max(ans_tree[now].solve[0],ans_tree[now].solve[1]),min(ans_tree[now].solve[2],ans_tree[now].solve[3]),max(ans_tree[now].solve[2],ans_tree[now].solve[3]));
					ans_tree[now].solve[i] -= ans_tree[now].solve[j]; 
				}
			}
		}
	}
	
}
string str(int num)
{
	string ans,ap;
	int rest=num;
	if (num == 0)
	{
		return "0";
	}
	while (rest>0)
	{
		ap=(rest%10)+'0';
		ans.insert(0,ap);
		rest/=10;
	}
	return ans;
}//读入一个int,返还其string类型 
void cout_subtree(int root,int k)
{
	this_v.push_back(root);
	while (this_v.empty() == 0 && k--)
	{
		line5 = "";
		for (int it : this_v)
		{
			line1 = line1 + (ans_tree[it].situ[0] >= 10 ? 'X' : (char)(ans_tree[it].situ[0] + '0')) + "  " + (ans_tree[it].situ[1] >= 10 ? 'X' : (char)(ans_tree[it].situ[1] + '0')) + "     ";
			line2 = line2 + (ans_tree[it].situ[2] >= 10 ? 'X' : (char)(ans_tree[it].situ[2] + '0')) + "  " + (ans_tree[it].situ[3] >= 10 ? 'X' : (char)(ans_tree[it].situ[3] + '0')) + "     ";
			line3 = line1;
			line4 = line4 + (ans_tree[it].solve[2] >= 10 ? 'X' : (char)(ans_tree[it].solve[2] + '0')) + "  " + (ans_tree[it].solve[3] >= 10 ? 'X' : (char)(ans_tree[it].solve[3] + '0')) + "     ";
			line5 = line5 + "(" + str(it) + ")";
			for (int j = 1;j <= (int)(7 - str(it).length());j++)
			{
				line5 = line5 + " ";
			}
			int zhi = 0;
			while (ans_tree[it].son[zhi] != 0 && zhi < 4)
			{
				next_v.push_back(ans_tree[it].son[zhi]);
				zhi++;
			}
		}
		cout << line1 << "\n" << line2 << "\n" << line3 << "\n" << line4 << "\n\n";
		line1 = line2 = line3 = line4 = "";
		swap(this_v,next_v);
		vector <int> emp;
		swap(next_v,emp);
	}
	cout << line5 << "\n\n";
	line5 = "";
	vector <int> emp;
	swap(this_v,emp);
}
int main()
{
	freopen("Ans-Tree.txt","w",stdout);
	dfs(0);
	make_tree(1,1,2,1,1);
	int ask,depth;
	scanf("%d %d",&ask,&depth);
	cout_subtree(ask,depth);
	return 0;
}
共 4 篇
  1. 生活·游记

    2024 CSP-S 日照行【施工中】

    这是一篇记录编程竞赛两天经历的游记。第一天作者与队友乘坐大巴前往考场,发现参赛人数较去年减少,且晚饭质量差价格高,引发吐槽。身体不适导致夜间难以入睡,担心第二天考试状态。第二天因感冒早起后状态不佳,复习算法时效率低下。考试中因迷路迟到,面对题目时出现理解偏差,最终通过仔细调试完成T1和T2题。过程中因忘记lower_bound函数使用而手写二分法,还借助对拍程序排查错误。全文透露出对考试的紧张、对饮食的不满以及身体不适带来的困扰。

    2 赞
  2. 个人记录

    2023 CSP-S日照行

    这是一篇关于2023年NOIp考试的游记,记录了作者与队友在考试前后的经历。第一天描述了补考卷、试机时的迷路趣事及考场环境的不适,如设备键盘布局陌生、机位隔板形同虚设等;第二天详细刻画了考试现场的紧张氛围,通过同学间的幽默对话(如freopen梗)缓解压力,最终因题目难度过高仅完成部分题解;第三天呈现了考试结束后的返程与反思,感慨OI生涯的成长历程。文中穿插了对竞赛的热爱、团队协作的温暖以及对未来的期许,最后以"从蒟蒻到选手"的蜕变和对美好回忆的珍视作结,展现了青少年在编程竞赛中的热血与青春。

    1 赞
  3. 个人记录

    2023 NOIp平邑行

    2023年11月17日至18日,作者记录了NOIp竞赛的两天经历。首日抵达平邑酒店时因电梯限制与室友Hanyt失联,但发现酒店环境优美,且平邑一中建筑风格独特。次日考试中,作者凭借暴力解法通过T1,但T2因误用BFS导致仅得20分,后改用DFS意外通过。最终因多次失误导致总分从120降至200分,虽成绩未达预期,但通过反思认识到竞赛过程中的同伴情谊比结果更珍贵。文中以"千骑拥高牙"等诗句表达对经历的感悟,虽有遗憾却释然接受。

  4. 生活·游记

    2024 NOIp淄博行&退役祭

    忆片·谁带来故事的种子·Day -inf(2021夏) 蝉鸣声穿过窗户,为安静的教室兀然添上了几分喧闹。盛夏的阳光也顺着窗棂摸了进来,只是大半火热被冰冰凉凉的玻璃留住。我正望着窗外浓密绿郁的树叶走神,却突然闻到一股甜甜的香味随着冷气飘过来。是他回来了。 教室门吱嘎一响,我微微侧过…

    33 赞