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. AWS 解决方案架构师考点(Storage)

    目录 一.S3 存储类 二.S3 考点 三.Storage Gateway 3.1.File Gateway 3.2.Volume Gateway /3.3.Tape Gateway 一.S3 存储类 ...

  2. Flutter FutureBuilder异步请求列表示例

    Flutter的FutureBuilder列表示例 import 'package:flutter/material.dart'; import '../service/service_method. ...

  3. Python(1)自动发送邮件

    python发邮件需要掌握两个模块的用法,smtplib和email,这俩模块是python自带的,只需import即可使用.smtplib模块主要负责发送邮件,email模块主要负责构造邮件. sm ...

  4. java、ruby、python、php等如何生成excel文档?

    excel在我们日常工作生活中会经常用到,通常我们都是用office软件去编写文档.但是对于格式一致的excel文档,如果还是使用人工完成,那绝不是我们软件工程师的姿态了~ 下面我就介绍一种方法,不需 ...

  5. 删除Excel表格中一堆英文中的汉字

    昨天需要处理一个Excel文件,删除一堆英文里的汉字,开始搜了下方法,没找到,然后手动一个多小时,弄了一半吧也就,结果电脑卡了,忘了保存,就白做了...不知道为啥这次没有自动保存,所以,重要的事说三遍 ...

  6. 【VS开发】TCP服务端如何判断客户端断开连接

    原文出自:http://www.cnblogs.com/youxin/p/4056041.html 一篇文章:   最近在做一个服务器端程序,C/S结构.功能方面比较简单就是client端与serve ...

  7. B9 Concurrent 重入锁(ReentrantLock)

    [概述] java.util.concurrent.locks.ReentrantLock 实现 java.util.concurrent.locks.Lock 接口,加锁(lock)和 解锁(unl ...

  8. [转帖]详解Linux系统inode原理--硬链接、软链接、innodb大小和划分等

    详解Linux系统inode原理--硬链接.软链接.innodb大小和划分等 原创 波波说运维 2019-07-17 00:03:00 https://www.toutiao.com/i6713116 ...

  9. 【51nod】1602 矩阵方程的解

    [51nod]1602 矩阵方程的解 这个行向量显然就是莫比乌斯函数啦,好蠢的隐藏方法= = 然后我们尝试二分,二分的话要求一个这个东西 \(H(n) = \sum_{i = 1}^{n} \mu(i ...

  10. 汉字在unicode中的位置

    在www.unicode.org中查找汉字.china找不到,后来查资料才明白,应该查CJK,为什么内? unicode这个组织吧中国日本韩国的字合并了   中日韩统一表意文字(CJK Unified ...