| 比赛 |
NOIP2025模拟赛1 |
评测结果 |
AAAAAAAAAA |
| 题目名称 |
接竹竿 |
最终得分 |
100 |
| 用户昵称 |
梦那边的没好TM |
运行时间 |
2.423 s |
| 代码语言 |
C++ |
内存使用 |
3.88 MiB |
| 提交时间 |
2025-11-24 09:57:48 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define cpy(a,b) copy(begin(a),end(a),begin(b))
#define ld long double
#define dot(x) fixed<<setprecision(x)
#define foru(a,b,c) for(ll a=b;a<=c;a++)
#define ford(a,b,c) for(ll a=b;a>=c;a--)
ll t,n,q,a[15005],pos[15],nxt[15005];
int main(){
freopen("bamboo.in" ,"r",stdin );
freopen("bamboo.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin>>t;
while(t--){
cin>>n;
foru(i,1,n){
cin>>a[i];
}
foru(i,0,14){
pos[i]=INT_MAX;
}
ford(i,n,1){
nxt[i]=pos[a[i]];
pos[a[i]]=i;
}
cin>>q;
foru(i,1,q){
ll l,r;
cin>>l>>r;
ll now=l,ans=0;
while(now<=r){
if(nxt[now]<=r){
now=nxt[now]+1;
}else{
now++;
ans++;
}
}
cout<<ans<<endl;
}
}
return 0;
}