当前位置:网站首页>L2-040 哲哲打游戏 (25 分) 模拟
L2-040 哲哲打游戏 (25 分) 模拟
2022-04-21 16:38:00 【wow_awsl_qwq】
哲哲是一位硬核游戏玩家。最近一款名叫《达诺达诺》的新游戏刚刚上市,哲哲自然要快速攻略游戏,守护硬核游戏玩家的一切!
为简化模型,我们不妨假设游戏有 N 个剧情点,通过游戏里不同的操作或选择可以从某个剧情点去往另外一个剧情点。此外,游戏还设置了一些存档,在某个剧情点可以将玩家的游戏进度保存在一个档位上,读取存档后可以回到剧情点,重新进行操作或者选择,到达不同的剧情点。
为了追踪硬核游戏玩家哲哲的攻略进度,你打算写一个程序来完成这个工作。假设你已经知道了游戏的全部剧情点和流程,以及哲哲的游戏操作,请你输出哲哲的游戏进度。
输入格式:
输入第一行是两个正整数 N 和 M (1≤N,M≤10
5
),表示总共有 N 个剧情点,哲哲有 M 个游戏操作。
接下来的 N 行,每行对应一个剧情点的发展设定。第 i 行的第一个数字是 K
i
,表示剧情点 i 通过一些操作或选择能去往下面 K
i
个剧情点;接下来有 K
i
个数字,第 k 个数字表示做第 k 个操作或选择可以去往的剧情点编号。
最后有 M 行,每行第一个数字是 0、1 或 2,分别表示:
0 表示哲哲做出了某个操作或选择,后面紧接着一个数字 j,表示哲哲在当前剧情点做出了第 j 个选择。我们保证哲哲的选择永远是合法的。
1 表示哲哲进行了一次存档,后面紧接着是一个数字 j,表示存档放在了第 j 个档位上。
2 表示哲哲进行了一次读取存档的操作,后面紧接着是一个数字 j,表示读取了放在第 j 个位置的存档。
约定:所有操作或选择以及剧情点编号都从 1 号开始。存档的档位不超过 100 个,编号也从 1 开始。游戏默认从 1 号剧情点开始。总的选项数(即 ∑K
i
)不超过 10
6
。
输出格式:
对于每个 1(即存档)操作,在一行中输出存档的剧情点编号。
最后一行输出哲哲最后到达的剧情点编号。
输入样例:
10 11
3 2 3 4
1 6
3 4 7 5
1 3
1 9
2 3 5
3 1 8 5
1 9
2 8 10
0
1 1
0 3
0 1
1 2
0 2
0 2
2 2
0 3
0 1
1 1
0 2
输出样例:
1
3
9
10
样例解释:
简单给出样例中经过的剧情点顺序:
1 -> 4 -> 3 -> 7 -> 8 -> 3 -> 5 -> 9 -> 10。
档位 1 开始存的是 1 号剧情点;档位 2 存的是 3 号剧情点;档位 1 后来又存了 9 号剧情点。
#include<bits/stdc++.h>
using namespace std;
const int N=100004;
vector<int> v[N];
int dan[N],p=1;
int main()
{
int n,m;cin>>n>>m;
for(int i=1;i<=n;++i)
{
int k;cin>>k;
while(k--){
int x;cin>>x;
v[i].push_back(x);
}
}
while(m--)
{
int x,y;cin>>x>>y;
if(x==0){
p=v[p][y-1];
}else if(x==1){
dan[y]=p;
cout<<p<<endl;
}else {
p=dan[y];
}
}
cout<<p;
return 0;
}
版权声明
本文为[wow_awsl_qwq]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_42641977/article/details/124312330
边栏推荐
- Find the longest substring of a string
- 下载Chrome插件安装到浏览器
- 4.25 unlock openharmony technology day! The annual event is about to open!
- 2022 bone conduction earphone ranking, the best bone conduction earphone recommended
- Invalid bound statement (not found)问题解决
- 目前5G SoC 芯片技术成熟吗?
- 云安全日报220421:思科虚拟化基础设施管理器软件发现权限提升漏洞,需要尽快升级
- Which exchange is rapeseed meal futures listed on? How is it safest for a novice to open a futures account?
- The elmentui drop-down box realizes all functions
- C语言程序的环境,编译+链接
猜你喜欢
掌握自动化测试必要的几种技能?

囤货之余,该重新认识罐头了

Yunna: Problems and causes of hospital fixed assets management, implementation of asset management system

iOS开发面试攻略(KVO、KVC、多线程、锁、runloop、计时器)

【面试普通人VS高手系列】能谈一下CAS机制吗?

Summary of DOM operation elements

MinGW Download

How does PHP convert negative numbers to positive integers

The elmentui drop-down box realizes all functions

What kind of earphone doesn't hurt your ears? Bone conduction earphone for non ear wearing
随机推荐
Pfsense和Snorby
Want to make a fortune by "leaking data"? What a punishment
微软IE本地文件读取漏洞
Which exchange is rapeseed meal futures listed on? How is it safest for a novice to open a futures account?
What are the similarities and differences between LCD and OLED screens
微软IE本地文件探测漏洞
mysql查询某一个字段是否包含中文汉字
4.25 unlock openharmony technology day! The annual event is about to open!
What are the mainstream types of mobile phone screens at present
Sogou website divulges information
OJ daily practice - number of characters
What are the mobile phone hardware
Add release configuration in clion
搜狗网站泄露信息
囤货之余,该重新认识罐头了
巴比特副总裁马千里:元宇宙时代NPC崛起,数字身份协议或成为入口级产品丨2022元宇宙云峰会
Teach you how to do orb slam3 with oak-d and ROS noetic based on LXD
Is 5g SOC chip technology mature at present?
MinGW Download
C# 滑动验证码|拼图验证|SlideCaptcha