题目描述

A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.

Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i i i , he makes a note in his logbook with number ti t_{i} ti​ :

  • If Petya has visited this room before, he writes down the minute he was in this room last time;
  • Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i i i .

Initially, Petya was in one of the rooms at minute 0 0 0 , he didn't write down number t0 t_{0} t0​ .

At some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?

输入输出格式

输入格式:

The first line contains a single integer n n n ( 1<=n<=2⋅105 1<=n<=2·10^{5} 1<=n<=2⋅105 ) — then number of notes in Petya's logbook.

The second line contains n n n non-negative integers t1,t2,...,tn t_{1},t_{2},...,t_{n} t1​,t2​,...,tn​ ( $ 0<=t_{i}&lt;i $ ) — notes in the logbook.

输出格式:

In the only line print a single integer — the minimum possible number of rooms in Paris catacombs.

题目翻译:

一位非常勇敢的探险家佩蒂娅曾经决定去探索巴黎的地下墓穴。由于佩蒂亚没有真正的经验,他的探索只是走过地下墓穴。              地下墓穴由几个房间和一些房间对之间的双向通道组成。有些通道可以把一个房间连接起来,由于通道是在不同的深度上建造的,所以它们之间不会相交。每一分钟,佩蒂娅都会任意地从他现在所在的房间中选择一条通道,然后在一分钟内到达通道另一端的房间。当他在第一分钟进入一个房间时,他会在日志中记下号码ti:              如果佩蒂亚以前去过这个房间,他会写下他上次在这个房间的时间;              否则,petya会严格地写下一个小于当前分钟i的任意非负整数。              起初,佩蒂亚在第0分钟的时候在其中一个房间里,他没有写下数字t0。              在他流浪期间的某个时候,佩蒂娅累了,扔掉了他的航海日志,回家了。瓦西亚找到了他的航海日志,现在他很好奇:根据佩蒂娅的航海日志,巴黎地下墓穴的最小房间数是多少?

输入1:

2
0 0

输出1:

2

输入2:

5
0 1 0 1 3

输出2:

3

 #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
const int maxn=*1e5+;
int a[maxn]; int main(){
int n;
cin>>n;
memset(a,,sizeof(a));
int x;
int ans=;
while(n--){
cin>>x;
if(!a[x]){
a[x]=;
}
else{
ans++;
}
}
cout<<ans<<endl;
return ;
}

CF886C Petya and Catacombs的更多相关文章

  1. Codeforces 890C - Petya and Catacombs 模拟

    C. Petya and Catacombstime limit per test1 secondmemory limit per test256 megabytesinputstandard inp ...

  2. codeforce 886C Petya and Catacombs (map,思路)

    突然发现百度不到这题的单独题解(果然是因为这是水题么),那我就来写一个了~ 先把题给贴了. C. Petya and Catacombs time limit per test 1 second me ...

  3. Codeforces Round #445 C. Petya and Catacombs【思维/题意】

    C. Petya and Catacombs time limit per test 1 second memory limit per test 256 megabytes input standa ...

  4. Codeforce 886 Технокубок 2018 - Отборочный Раунд 3 C. Petya and Catacombs(结论题)

    A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really exper ...

  5. 【Codeforces Round #445 (Div. 2) C】 Petya and Catacombs

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 看看时间戳为i的点有哪些. 每次优先用已经访问过的点. 如果不行就新创一个点. 注意新创点的时间戳也是i. [代码] #includ ...

  6. 886C. Petya and Catacombs#墓室探险(set集合)

    题目出处:http://codeforces.com/problemset/problem/886/C 题目大意:很多墓穴之间有通道,探险家来回穿梭并记录日志 日志规则:第一次到该墓穴计时间t,0&l ...

  7. codeforces 889A

    A. Petya and Catacombs time limit per test 1 second memory limit per test 256 megabytes input standa ...

  8. Codeforces Round #445

    ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #inclu ...

  9. Petya勒索木马

    同事小学妹神好奇心,在陌生群里下载了个软件,接下来就是自动重启无法开机. 找我一看,凭我专业帮妹纸装系统多年的经验,起初也不觉得有啥困难,兼容模式下重启,接下来出现这个: 按下any key后: 试了 ...

随机推荐

  1. .Net转Java.03.受查异常和非受查异常

    转到Java以后发现一个很妖的事情,为啥有些方法后边有个 throws XXXXException 比如下面的代码 @Override public <T> ResponseEntity& ...

  2. java 使用CXF将wsdl文件生成客户端代码命令java调用第三方的webservice应用实例

    1.先下载cxf包https://download.csdn.net/download/suizhikuo/108112362.解压缩包,通过cmd命令进入到bin目录下(cd cxf\bin的路径) ...

  3. 05、transformation操作开发实战

    1.map:将集合中每个元素乘以2 2.filter:过滤出集合中的偶数 3.flatMap:将行拆分为单词 4.groupByKey:将每个班级的成绩进行分组 5.reduceByKey:统计每个班 ...

  4. HOWTO: Avizo/Amira使用前的显卡设置(Volume Rendering,Volren不显示)

    关于Avizo或Amira中体渲染不显示的问题,常常有人在问,有人甚至怀疑软件有问题,今天就这个话题总结如下: 首先我们要清楚像Avizo或Amira之类的三维可视化软件,必须是在配有专业显卡的工作站 ...

  5. CentOS7通过rsync+crontab实现两台服务器文件同步

    centos7系统中已经默认安装rsync 1:主服务器配置 (1)修改rsyncd.conf 配置文件 [root@localhost app]# vi /etc/rsyncd.conf motd ...

  6. JavaWeb开发的一些问题

    从今天开始,在此帖陆续会记录一些平时所遇到的一些问题 1.20181229 org.apache.ibatis.binding.BindingException: Invalid bound stat ...

  7. LeetCode: Gray Code [089]

    [题目] The gray code is a binary numeral system where two successive values differ in only one bit. Gi ...

  8. 关于docker 意外停止,重新快速启动措施

    1. 我们要重启这个镜像,需要知道这个镜像ID,类似这个: 7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252 那么你可以 ...

  9. MySQL 服务常用操作命令

    1.MySQL 服务设置 在使用 mysql.server 命令之前需要将路径 /usr/local/mysql/support-files 添加到系统环境变量中. export PATH=$PATH ...

  10. Linux下统计当前文件夹下的文件个数、目录个数

    统计当前文件夹下文件的个数,包括子文件夹里的 ls -lR|grep "^-"|wc -l 统计文件夹下目录的个数,包括子文件夹里的 ls -lR|grep "^d&qu ...