http://codeforces.com/contest/368/problem/B

从后往前找一遍就可以。

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 200000
using namespace std; int dp[maxn];
int n,m;
int a[maxn];
bool vis[maxn]; int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
memset(dp,,sizeof(dp));
memset(vis,false,sizeof(vis));
int t1=;
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
}
for(int i=n; i>=; i--)
{
if(!vis[a[i]])
{
vis[a[i]]=true;
t1++;
dp[i]=t1;
}
else
{
dp[i]=t1;
}
}
for(int i=; i<=m; i++)
{
int x;
scanf("%d",&x);
printf("%d\n",dp[x]);
}
}
return ;
}

cf B. Sereja and Suffixes的更多相关文章

  1. B. Sereja and Suffixes(cf)

    http://codeforces.com/problemset/problem/368/B B. Sereja and Suffixes time limit per test 1 second m ...

  2. Codeforces Round #215 (Div. 2) B. Sereja and Suffixes map

    B. Sereja and Suffixes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...

  3. Sereja and Suffixes(思维)

    Sereja and Suffixes Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64 ...

  4. B. Sereja and Suffixes

    B. Sereja and Suffixes time limit per test 1 second memory limit per test 256 megabytes input standa ...

  5. Codeforces Round #215 (Div. 2) B. Sereja and Suffixes

    #include <iostream> #include <vector> #include <algorithm> #include <set> us ...

  6. CF 314C Sereja and Subsequences(树状数组)

    题目链接:http://codeforces.com/problemset/problem/314/C 题意:给定一个数列a.(1)写出a的不同的所有非下降子列:(2)定义某个子列的f值为数列中各个数 ...

  7. CodeForces 368B Sereja and Suffixes

    题意:给你一个序列,问你从l位置到结尾有多少个不同的数字. 水题,设dp[i]表示从i位置到结尾不同数字的个数,那么dp[i] = dp[i+1] + (vis[a[i]] == 0),在O(n)时间 ...

  8. Sereja and Suffixes

    Codeforces Round #215 (Div. 2) B:http://codeforces.com/problemset/problem/368/B 题意:给你一个序列,然后查询i--n中没 ...

  9. cf D. Sereja ans Anagrams

    http://codeforces.com/contest/368/problem/D #include <cstdio> #include <cstring> #includ ...

随机推荐

  1. PullToRefreshListView 内嵌checkbox 数据丢失问题

    在PullToRefreshListView 内部内嵌了Checkbox如下图所示: 原本设计思路是:对CheckBox 进行 setOnCheckedChangeListener 监听 当Check ...

  2. 2014-07-31 ASP.NET的母版页使用

    今天是在吾索实习的第17天.我在这天主要负责系统的骨架的搭建.首当其冲,要用的知识点就是ASP.NET母版页的使用了. ASP.NET的母版页有两种:一种是MasterPage,最常用也是最普通的母版 ...

  3. 大型分布式C++框架《一:框架简介》

    首先名字要取得霸气才能吸引人气,哈哈~~ 下面简单介绍下情况.框架是腾讯电商平台的分布式框架.虽然腾讯拍拍已经玩完了.但是这套框架还是很不错的.而且据原腾讯同事说微信也是用的这套框架.源码肯定是不能说 ...

  4. 一条sql

    包含全部:SELECT u.id,u.user_name,usa.fixed_amount,d.uloadtype,d.min_loan_money FROM fanwe_user_autobid u ...

  5. ubuntu dash

    缘由:写一些脚本放在/etc/rc.loca自动执行开机启动报错 fiail to start /etc/rc.local 查找资料 缘起:ubuntu在6.0后默认bash改为了dash  导致很多 ...

  6. js过滤空格

    点击查看效果 点击进入下载 <html> <head> <title> 过滤空格 </title> <SCRIPT LANGUAGE=" ...

  7. 自定义控件 环形进度条 ProgressBar

    使用 public class MainActivity extends Activity implements OnComompleteListener {     private int num  ...

  8. CSharp命名风格

    1.大小写约定 为了区分一个标识符中的多个单词,把标识符中的每个单词的首字母大写.不要用下划线来区分单词,或者在标识符中任何地方使用下划线,有两种方式适合大写标识符的字母: PascalCasing( ...

  9. this——笔记

    this是执行上下文中的一个属性.this与上下文中可执行代码的类型有直接关系,this值在进入上下文时确定,并且在上下文运行期间永久不变. 在这里一切都简单.在全局代码中,this始终是全局对象本身 ...

  10. (转)几种HtmlEncode的区别

    一.C#中的编码 HttpUtility.HtmlDecode.HttpUtility.HtmlEncode与Server.HtmlDecode.Server.HtmlEncode与HttpServe ...