跳到正文

题解

题解 CF1293A 【ConneR and the A.R.C. Markland-N】

gyh20约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年6月14日
更新
2026年6月14日
篇幅
约 1 分钟
题目
CF1293A

版本

  1. v1当前

因为k<=1000k<=1000,所以只用看是否又可以到的距离小于等于10001000的楼,只用存到当前位置距离小于等于10001000的即可。

代码:

C++
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#define re register
using namespace std;
int t,n,a,b,c;
int v[1002];
int ans;
signed main(){
scanf("%d",&t);
while(t--){
	ans=(1<<30);
	memset(v,0,sizeof(v));
	scanf("%d%d%d",&n,&a,&b);
	for(re int i=1;i<=b;++i){
		scanf("%d",&c);
		if(abs(c-a)<=1000)++v[abs(c-a)];
	}
	for(re int i=a;i<=1000;++i)++v[i];
	for(re int i=n-a+1;i<=1000;++i)++v[i];
	if(!v[0])ans=0;
	else{
		for(re int i=1;i<=1000;++i)if(v[i]<2){
			ans=i;
			break;
		}
	}
	printf("%d\n",ans);
}
	}
原文