比赛 NOIP2025模拟赛1 评测结果 AAAAAAAAAA
题目名称 接竹竿 最终得分 100
用户昵称 梦那边的美好ME 运行时间 1.251 s
代码语言 C++ 内存使用 3.74 MiB
提交时间 2025-11-24 10:13:34
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define int register unsigned


signed main(){
	freopen("bamboo.in","r",stdin);
	freopen("bamboo.out","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T,n,q;
	int ans;
	cin>>T;
	while (T--){
		cin>>n;
		int f[16]={0};
		int t[16000]={0};
		for (int i=1;i<=n;i++){
			int x;
			cin>>x;
			t[f[x]]=i;
			f[x]=i;
		}
		cin>>q;
		while (q--){
			int l,r;
			ans=0;
			cin>>l>>r;
			for (int i=l;i<=r;i++){
				if (t[i]<l||t[i]>r) ans++;
				else i=t[i]; 
			}
			cout<<ans<<'\n';
		}
	}
	return 0;
}