• I


     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 #include<map>
     5 #include<vector>
     6 using namespace std;
     7 const int N=1e5+10;
     8 int n,m;
     9 int a[N];
    10 map<int,int>h;
    11 
    12 int main()
    13 {
    14     while (~scanf("%d%d",&n,&m)) {
    15         h.clear();
    16         vector<int>g[N];
    17         int tot=0;
    18         for (int i=1;i<=n;i++) {
    19             scanf("%d",&a[i]);
    20             if (h[a[i]]==0) {
    21                 h[a[i]]=++tot;
    22                 a[i]=tot;
    23             }
    24             else a[i]=h[a[i]];
    25             g[a[i]].push_back(i);
    26         }
    27         while (m--) {
    28             int l,r,x;
    29             scanf("%d%d%d",&l,&r,&x);
    30             if (h[x]==0) {
    31                 printf("0 ");
    32                 continue;
    33             }
    34             x=h[x];
    35             l=lower_bound(g[x].begin(),g[x].end(),l)-g[x].begin();
    36             r=upper_bound(g[x].begin(),g[x].end(),r)-g[x].begin();
    37             printf("%d ",r-l);
    38         }
    39     }
    40     return 0;
    41 }
    View Code
  • 相关阅读:
    firFox的HttpRequest插件的使用
    注解事务
    log4j配置说明
    对反射用法的初探
    关于set集合和Iterator迭代器的使用
    Eclipse的使用
    各种地图坐标系转换工具
    day67-CSS字体属性、文字属性、背景属性、css盒子模型
    day66-CSS伪类选择器和伪元素选择器
    day65-CSS选择器和样式优先级
  • 原文地址:https://www.cnblogs.com/acvc/p/4419861.html
Copyright © 2020-2023  润新知