CF886C Petya and Catacombs
题目描述
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}<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的更多相关文章
- Codeforces 890C - Petya and Catacombs 模拟
C. Petya and Catacombstime limit per test1 secondmemory limit per test256 megabytesinputstandard inp ...
- codeforce 886C Petya and Catacombs (map,思路)
突然发现百度不到这题的单独题解(果然是因为这是水题么),那我就来写一个了~ 先把题给贴了. C. Petya and Catacombs time limit per test 1 second me ...
- 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 ...
- 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 ...
- 【Codeforces Round #445 (Div. 2) C】 Petya and Catacombs
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 看看时间戳为i的点有哪些. 每次优先用已经访问过的点. 如果不行就新创一个点. 注意新创点的时间戳也是i. [代码] #includ ...
- 886C. Petya and Catacombs#墓室探险(set集合)
题目出处:http://codeforces.com/problemset/problem/886/C 题目大意:很多墓穴之间有通道,探险家来回穿梭并记录日志 日志规则:第一次到该墓穴计时间t,0&l ...
- codeforces 889A
A. Petya and Catacombs time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #445
ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #inclu ...
- Petya勒索木马
同事小学妹神好奇心,在陌生群里下载了个软件,接下来就是自动重启无法开机. 找我一看,凭我专业帮妹纸装系统多年的经验,起初也不觉得有啥困难,兼容模式下重启,接下来出现这个: 按下any key后: 试了 ...
随机推荐
- 对图片进行透明化处理-使用java程序
因需要将一张白色背景图片处理为透明色,因此上网上搜了搜处理方案,可以通过ps,和美图秀秀,但是我电脑上并没有这两个软件,下载安装太耗时.从网上搜了搜发现原来可以使用java代码进行处理,代码如下: i ...
- 【算法随记】Canny边缘检测算法实现和优化分析。
以前的博文大部分都写的非常详细,有很多分析过程,不过写起来确实很累人,一般一篇好的文章要整理个三四天,但是,时间越来越紧张,后续的一些算法可能就以随记的方式,把实现过程的一些比较容易出错和有价值的细节 ...
- [Python设计模式] 第24章 加薪审批——职责链模式
github地址:https://github.com/cheesezh/python_design_patterns 题目 用程序模拟以下情景 员工向经理发起加薪申请,经理无权决定,需要向总监汇报, ...
- 先打11.2.0.3.8这个PSU,后建库
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; Session altered. SQL> select c ...
- iOS ReplayKit实时录制屏幕实现方案的细节记录
项目有个需求,需要把ios设备上的操作画面实时传输出去,也就是类似推流手机直播画面的方案. 一番调研后发现在ios中,我们可以通过ios自带ReplayKit框架实现. 关于ReplayKit的讲解, ...
- 试水STF(smartphone test farm)
STF简介 简介: STF , smartphone test farm, 是一款能够通过浏览器远程管理智能设备的系统, 能为移动自动化测试提供方便快捷的服务,免去测试工程师的后顾之忧. 功能点: 支 ...
- redis学习 (key)键,Python操作redis 键 (二)
# -*- coding: utf-8 -*- import redis #这个redis 连接不能用,请根据自己的需要修改 r =redis.Redis(host=") 1. delete ...
- PHPStorm + Homestead + Xdebug + Chrome Xdebug Helper 调试配置
话说 PHPStorm 写起代码来非常带感,各种提示补全和纠错,以及在 L5 中的命名空间功能更是强大到感动(新建类自动添加命名空间,自动引入命名空间,返回参数命名空间纠正等等).当然它的调试功能更是 ...
- css3+svg实现波浪图
<!DOCTYPE html> <html> <head> <meta charset=utf-8> <title>css+svg实现波浪图 ...
- 强化学习-时序差分算法(TD)和SARAS法
1. 前言 我们前面介绍了第一个Model Free的模型蒙特卡洛算法.蒙特卡罗法在估计价值时使用了完整序列的长期回报.而且蒙特卡洛法有较大的方差,模型不是很稳定.本节我们介绍时序差分法,时序差分法不 ...