ABC335C - Loong Tracking

23 篇文章 0 订阅

problem link

A brute force solution to this problem would be modifying all n n n body parts with each move. However, one might notice that we don’t have to maintain the entire snake body dynamically. Since each part will take the place of the previous part, the i i ith part will always be i − 1 i-1 i1 indices down from the snake head.

With this conclusion, we can simply update the snake head position in a stack-like data structure. In each new move, we append the new position of the snake head to the stack. During queries, the i i ith body part would be the i i ith element down the stack. This gives us O ( n + q ) \mathcal O(n+q) O(n+q) complexity.

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
const int Maxn=2e6+10;
int a[Maxn],b[Maxn];
int n,q,cnt;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')w-=1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
	// freopen("in.txt","r",stdin);
	n=read(),q=read(),cnt=n;
	for(int i=1;i<=n;++i)
	a[i]=n-i+1;
	while(q--)
	{
		int opt=read();
		if(opt==1)
		{
			// printf("mod\n");
			string s;
			cin>>s;
			int x=a[cnt],y=b[cnt];
			if(s[0]=='U')++y;
			if(s[0]=='D')--y;
			if(s[0]=='L')--x;
			if(s[0]=='R')++x;
			a[++cnt]=x;
			b[cnt]=y;
		}
		else
		{
			int p=read();
			printf("%d %d\n",a[cnt-p+1],b[cnt-p+1]);
		}
	}
	return 0;
}
  • 10
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的信息,"no checksum found in checksum file for \"electron-v20.0.3-linux-loong64.zip" 的意思是在名为 "electron-v20.0.3-linux-loong64.zip" 的文件的校验和文件中未找到校验和。 校验和是通过对文件的内容执行特定算法生成的唯一标识符。它用于确保文件在传输或存储过程中没有损坏或被篡改。通常情况下,校验和会与文件一起发布,以供下载者或接收者验证文件的完整性。 然而,在这种情况下,校验和文件中未能找到与所提供的文件匹配的校验和。这可能是因为校验和文件本身存在问题或损坏,或者校验和文件与所提供的文件不匹配。 为了解决这个问题,可以尝试以下几个步骤: 1. 首先,确认校验和文件是否可用。检查校验和文件的来源和完整性。如果该文件来自一个不可靠的或有问题的来源,或者文件本身已被篡改,那么可能需要寻找其他来源的校验和文件。 2. 如果确定校验和文件是正确的,那么可能需要重新下载所提供的文件。确保从可靠的来源下载文件,并使用下载工具进行完整性检查,以确保下载的文件没有损坏。 3. 如果问题仍然存在,那么可能需要联系文件的发布者或提供者,寻求帮助或获取正确的校验和文件。 总之,校验和文件的缺失可能是由于校验和文件本身的问题或所提供文件与校验和文件不匹配导致的。通过检查校验和文件的来源和完整性,重新下载文件以及联系发布者或提供者,可以解决这个问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值