关于第 #11 号点
查看原帖
关于第 #11 号点
930506
Bill_luogu楼主2025/6/28 22:41

这份代码极限卡过 #11 :

#include<iostream>
#include<cstdio>
using namespace std;
long long t,q,n,ans,x,y,i;
int main()
{
 //    ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	scanf("%lld",&t);
	while(t--)
	{
    	scanf("%lld",&n);
        long long where[150001]={},where2[14]={};
		for(i=1;i<=n;i++)
			scanf("%lld",&x),where[where2[x]]=i,where2[x]=i;
		scanf("%lld",&q);
		while(q--)
		{
			scanf("%lld%lld",&x,&y);
			ans=0;
			for(i=x;i<=y;i++)
			{
				if(where[i]<x||where[i]>y)ans++;
				else i=where[i];
			}
			printf("%lld\n",ans);
		}
	}
	return 0;
} 

2025/6/28 22:41
加载中...