zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    arpspoof局域网断网攻击
    2019-2020 SEERC 2019
    2019-2020 XX Open Cup, Grand Prix of Korea
    欧拉函数板子
    Syncthing – 数据同步利器
    程序员的修养 -- 如何写日志(logging)
    css基础
    vim永久设置主题
    基金选择
    如何查看ntp端口是否正常
  • 原文地址:https://www.cnblogs.com/acvc/p/4419861.html
Copyright © 2011-2022 走看看