【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

看看时间戳为i的点有哪些。
每次优先用已经访问过的点。
如果不行就新创一个点。
注意新创点的时间戳也是i.

【代码】

#include <bits/stdc++.h>
using namespace std; const int N = 2e5; int n;
int now = 1, tot = 1;
vector <int> have[N + 10];
int before[N + 10]; int main() {
//freopen("F:\\c++source\\rush_in.txt", "r", stdin);
int n;
scanf("%d", &n);
int x;
scanf("%d", &x);
have[1].push_back(tot);
before[tot] = 1; for (int i = 2; i <= n; i++) {
scanf("%d", &x);
if (!have[x].empty()) {
now = have[x].back();
have[x].pop_back();
before[now] = i;
have[i].push_back(now);
}
else {
tot++;
have[i].push_back(tot);
before[tot] = i;
}
}
printf("%d\n", tot); return 0;
}

【Codeforces Round #445 (Div. 2) C】 Petya and Catacombs的更多相关文章

  1. 【Codeforces Round #445 (Div. 2) D】Restoration of string

    [链接] 我是链接,点我呀:) [题意] 给你n个字符串. 让你构造一个字符串s. 使得这n个字符串. 每个字符串都是s的子串. 且都是出现次数最多的子串. 要求s的长度最短,且s的字典序最小. [题 ...

  2. 【Codeforces Round #445 (Div. 2) B】Vlad and Cafes

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 傻逼模拟 [代码] #include <bits/stdc++.h> using namespace std; cons ...

  3. 【Codeforces Round #445 (Div. 2) A】ACM ICPC

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 三重循环 [代码] #include <bits/stdc++.h> using namespace std; int ...

  4. 【Codeforces Round #425 (Div. 2) B】Petya and Exam

    [Link]:http://codeforces.com/contest/832/problem/B [Description] *能代替一个字符串(由坏字母组成); ?能代替单个字符(由好字母组成) ...

  5. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  6. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  7. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  8. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  9. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

随机推荐

  1. 编译安装 gcc 4.9并验证使用

    编译安装 gcc 4.9并验证使用 1. 准备环境(GCC 编译器) centOS 6.3 cat /proc/version Linux version 2.6.32-279.el6.x86_64 ...

  2. Android学习笔记(三)

    ContentProvider简单介绍 ContentProvider是不同应用程序之间进行数据交换的标准API,当一个应用程序须要把自己的数据暴露给其它程序使用时.该应用程序便可通过提供Conten ...

  3. 什么时候用button,什么时候用a标签

    什么时候用button,什么时候用a标签 一.问题 能实现链接功能的标签一般就a标签,button标签,input submit标签 input submit肯定是提交表单的时候用 那什么时候用but ...

  4. Elasticsearch之shield(权限)插件安装之后的浏览详解

    前期博客 Elasticsearch-2.4.3的3节点安装(多种方式图文详解)(含 head.kopf.marvel.shield和watcher插件安装和使用) 访问es:-u es_admin ...

  5. Spring Cloud Netflix Eureka client源码分析

    1.client端 EurekaClient提供三个功能: EurekaClient API contracts are:* - provide the ability to get Instance ...

  6. Android 关于::app:clean :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE,引用jar冲突问题

    错误提示: Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTest ...

  7. 2017国家集训队作业[agc006e]Rotate 3x3

    2017国家集训队作业[agc006e]Rotate 3x3 题意: ​ 给你一个\(3*N\)的网格,每次操作选择一个\(3*3\)的网格,旋转\(180^\circ\).问可不可以使每个位置\(( ...

  8. 韦东山ARM裸机笔记(1)

    1.一个嵌入式Linux系统的软件组成:单片机大全Bootloader-->Linux驱动-->Linux APP-->Linux GUI(Android/QT) 2.驱动程序=软件 ...

  9. less---查看文件

  10. 使用maven的tomcat:run进行web项目热部署

    近期又又一次看了一下maven的东西,事实上主要是由于去了解Jenkins,后期或许会补充jenkins的博文. 怎么在eclipse里面创建maven webproject,这边就不介绍了,參见:h ...