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. 【数据库开发】C++测试redis中的publish/subscribe

    运用 http://blog.csdn.net/xumaojun/article/details/51558237 中的redis_publisher.hredis_publisher.cpp red ...

  2. eclipse设置html js css自动提示

    eclipse也可以像Visual Studio 2008那样完全智能提示HTML/JS/CSS代码,使用eclipse自带的插件,无需另外安装插件,具体步骤如下 1.打开eclipse→Window ...

  3. Shiro认证、角色、权限

    Apache Shiro 是 Java 的一个安全框架.Shiro 可以帮助我们完成:认证.授权.加密.会话管理.与 Web 集成.缓存等. Shiro的内置Realm:IniRealm和JdbcRe ...

  4. linux系统中RAID10磁盘冗余阵列配置

    介绍:RAID10:需要至少四块(含)硬盘,兼具速度和安全性,但成本很高,RAID10用两个磁盘做RAID0,用其他两个做RAID1当备份. 配置流程: 第一步:在原有基础上为磁盘再填入五块磁盘(至少 ...

  5. RISC-V汇编指南

    原文出处:https://github.com/riscv/riscv-asm-manual/blob/master/riscv-asm.md RISC-V Assembly Programmer's ...

  6. [转帖]微软宣布即将开始大规模推送Windows 10 V1903重大版本更新

    微软宣布即将开始大规模推送Windows 10 V1903重大版本更新 https://www.cnbeta.com/articles/tech/894303.htm 微软要批量更新 1903了 bu ...

  7. Hadoop的eclipse的插件是怎么安装的?

    [学习笔记] 1)网上下载hadoop-eclipse-plugin-2.7.4.jar,将该jar包拷贝到Eclipse安装目录下的dropins文件夹下,我的目录是C:\Users\test\ec ...

  8. Python_OpenCV视频截取并保存

    在图像处理之前,我们需要对拿到手的数据进行筛选,对于视频,我们需要从中截取我们需要的一段或几段 整体思路比较简单,通过设定截取视频的起止时间(帧数),可以将该时间段内的图像保存为新的视频 直接上代码: ...

  9. Navicat连接Oracle数据库用户权限问题

    解决Navicat连接Oracle数据库用户权限问题: 第一步:在cmd窗口运行[sqlplus], 第二步:输入Oracle的用户名和口令连接Oracle数据库, 第三步:执行授权代码,给用户授予D ...

  10. HADOOP 与 jupyterlab 链接

    首先     咱们先把jdk1.0.0_60.tar.gz     和       hadoop-2.7.2.tar.gz    的压缩包放到root根目录下的opt文件夹下      如图: 然后  ...