P1563 [NOIP2016 提高组] 玩具谜题

题目通道(NOIP2016 提高组 玩具谜题 - 洛谷)

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
long long qw[300000];
string we[300000];
long long er[300000];
long long rt[300000];
int main(){
	long long a,s,d=1,f,g;
	cin>>a>>s;
	for (int i=1;i<=a;i++)
	{
		cin>>qw[i]>>we[i];
	}
	for (int i=1;i<=s;i++)
    {
    	cin>>er[i]>>rt[i];
	}
	for (int i=1;i<=s;i++)
    {
    	if (qw[d]==0)
    	{
    		if (er[i]==0)
    		{
    			d-=rt[i];
			}
			if (er[i]==1)
			{
				d+=rt[i];
			}
		if (d>a)
		d=d-a;
		else if (d<=0)
		d+=a;
		}
		else if (qw[d]==1)
		{
    		if (er[i]==0)
    		{
    			d+=rt[i];
			}
		    if (er[i]==1)
			{
				d-=rt[i];
			}
		if (d>a)
		d=d-a;
		else if (d<=0)
		d+=a;
		}
	}
	cout<<we[d];
	return 0;
}
相关推荐
h39742 小时前
DirectShow过滤器开发-视频源过滤器
c++·windows·音视频·directshow
程序猿编码4 小时前
榨干 RTX5090 算力!Qwen3 专用单卡推理引擎,手写C++/CUDA 算子实现 MTP 推测解码
开发语言·c++·大模型推理·qwen3·多模态推理
西飘客4 小时前
vs 怎么根据dll 生成lib文件
c++·qt
程序员老陆5 小时前
深入理解 C++ thread_local:线程私有存储的正确打开方式
开发语言·c++·程序设计
信奥卷王6 小时前
[GESP202609 六级] 分树规划
算法
夏幻灵6 小时前
LeetCode 21:合并两个有序链表——双指针与哑节点详解
算法·leetcode·链表
徐小黑ACG7 小时前
Golang 基础05 结构体struct
开发语言·算法·golang
码完就睡7 小时前
数据结构——红黑树
数据结构
码爸8 小时前
数据结构详细介绍
数据结构