1 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std; int a[];
int rd[]; int main()
{
set<int>s;
int n;
cin>>n;
for(int i=;i<=n;i++)
scanf("%d",&a[i]); for(int i=n;i>=;i--)
{
s.insert(a[i]);
rd[i]=s.size(); //预处理:记录 下标大于等于i并且不重复的a[i]的'数目'
}
s.clear(); long long sum=; //int会爆
for(int i=;i<=n;i++)
{
if(s.find(a[i]) == s.end() ) //如果还没有出现过a[i];
{
s.insert(a[i]); //那就加入a[i];
sum+= rd[i+]; //加上 下标在i之后(不包括i)的不重复的a[i] 数量
} //最后一个 rd[n+1]=0 默认等于0
}
cout<<sum<<endl;
} http://codeforces.com/group/1EzrFFyOc0/contest/1004/problem/C
 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std; const int maxn=1e5+;
int a[maxn];
int rd[maxn];
bool vis[maxn]; int main()
{
int n;
cin>>n;
for(int i=;i<=n;i++)
scanf("%d",&a[i]); for(int i=n;i>=;i--)
{
rd[i]=rd[i+]; //继承
if( !vis[a[i]] )
{
vis[a[i]]=;
rd[i]++;
}
}
memset(vis,,sizeof(vis));
ll sum=;
for(int i=;i<=n;i++)
{
if( !vis[a[i]] )
{
sum += rd[i+];
vis[a[i]]=;
}
}
cout<<sum<<endl;
}


Sonya and Robots的更多相关文章

  1. codeforces ~ 1004 C Sonya and Robots (dp)

    C. Sonya and Robots time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Sonya and Robots CodeForces - 1004C (思维题)

    Sonya and Robots time limit per test 1 second memory limit per test 256 megabytes input: standard in ...

  3. Sonya and Robots(CodeForces 1004C)

    Since Sonya is interested in robotics too, she decided to construct robots that will read and recogn ...

  4. Codeforces Round #495 (Div. 2) C. Sonya and Robots

    http://codeforces.com/contest/1004/problem/C 题意: 在一行上有n个数字,现在在最左边和最右边各放置一个机器人,左右机器人各有一个数字p和q.现在这两个机器 ...

  5. 网站 robots.txt 文件编写

    网站 robots.txt 文件编写 Intro robots.txt 是网站根目录下的一个纯文本文件,在这个文件中网站管理者可以声明该网站中不想被robots访问的部分,或者指定搜索引擎只收录指定的 ...

  6. Robots.txt - 禁止爬虫(转)

    Robots.txt - 禁止爬虫 robots.txt用于禁止网络爬虫访问网站指定目录.robots.txt的格式采用面向行的语法:空行.注释行(以#打头).规则行.规则行的格式为:Field: v ...

  7. (转载)robots.txt写法大全和robots.txt语法的作用

    1如果允许所有搜索引擎访问网站的所有部分的话 我们可以建立一个空白的文本文档,命名为robots.txt放在网站的根目录下即可.robots.txt写法如下:User-agent: *Disallow ...

  8. Codeforces713C Sonya and Problem Wihtout a Legend(DP)

    题目 Source http://codeforces.com/problemset/problem/713/C Description Sonya was unable to think of a ...

  9. 2016 ccpc 网络选拔赛 F. Robots

    Robots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

随机推荐

  1. Egret入门学习日记 --- 第十三篇(书中 5.2~5.3节 内容)

    第十三篇(书中 5.2~5.3节 内容) 写日记已经十天多了,我发现越到后面,我书写的方式越来越程序化. 感觉渐渐失去了人类所谓的感情似的. 不过,没想到的是,书中的内容,很少出现了错误,我一路过来到 ...

  2. 三节课MINI计划第四周

    一.任务 二.任务一 (一)梳理产品卖点 (二)策划线上活动 三.任务二 四.周报

  3. vue路由传参的三种方式

    方式一 通过query方式传参 这种情况下 query传递的参数会显示在url后面 this.$router.push({ path: '/detail', query: { id: id } }) ...

  4. git merge仓

    git merge --no-ff branch 合并指定代码 如果有冲突 git mergetool   可视化解决冲突, qa! 全退出 如果修复失败 git checkout branch -f ...

  5. TCP Socket + UDP Socket

    小例子:http://soft.yesky.com/238/2035738.shtml 服务器程序: #include <iostream> #include <WinSock2.h ...

  6. (生鲜项目)06. django的view实现商品列表页

    使用原始的django的View来返回json格式的商品列表 目的是回顾一些django的基础知识, 好与后面的RESTful做对比 goods.views_base.py from django.v ...

  7. windows服务器入门 php的安装

    下载PHP安装包(下载地址: http://windows.php.net/download/ ),本文档以5.3版本为例,选择如下图对应的安装包: 下载完成后进行安装PHP,需要选择Web服务时,选 ...

  8. [转载]Oracle触发器详解

    转载自http://blog.csdn.net/indexman/article/details/8023740/ 触发器是许多关系数据库系统都提供的一项技术.在oracle系统里,触发器类似过程和函 ...

  9. ASP.NET请求过程-Handler

    什么事Handler asp.net程序所有的请求都是handler处理的.以前的webform我们访问的地址是xxxxx.aspx地址,其实他也会到一个handler(我们写的业务代码都在handl ...

  10. vue.js中 ,回车键实现登录或者提交表单!

    vue的功能非常强大,但是我们作为一个后端开发人员,前端的东西不一定都弄的很明白,今天就给大家介绍一个回车提交表单的真实案例,达到回车登录的效果! @ keyup.enter 实现的效果 <in ...