/*
https://ac.nowcoder.com/acm/contest/917/H
n个数 m个询问(m,n<1e4) 这个n个数是大于等于0的
询问l --- r有多少等于k的值
题解:可以把a[i]当成下标 i当成数组
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
const int mod=20180623;
int a[N];
vector<int>vec[N];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
vec[a[i]].push_back(i);
}
while(m--){
int l1,r1,l2,r2,k;
scanf("%d %d %d %d %d",&l1,&r1,&l2,&r2,&k);
if(l1>r1) swap(l1,r1);
if(l2>r2) swap(l2,r2);
long long x=upper_bound(vec[k].begin(),vec[k].end(),r1)-lower_bound(vec[k].begin(),vec[k].end(),l1);
long long y=upper_bound(vec[k].begin(),vec[k].end(),r2)-lower_bound(vec[k].begin(),vec[k].end(),l2);
printf("%lld\n",x%mod);
printf("%lld\n",y%mod);
printf("%lld\n",((x%mod)*(y%mod))%mod);
}
ret
l~r区间查找等于k的数有多少个(主席树)
最新推荐文章于 2022-12-05 00:18:19 发布