Gym 100989F 水&愚&vector
standard input/output
You must have heard about Agent Mahone! Dr. Ibrahim hired him to catch the cheaters in the Algorithms course. N students cheated and failed this semester and they all want to know who Mahone is in order to take revenge!
Agent Mahone is planning to visit Amman this weekend. During his visit, there are M places where he might appear. The N students are trying to cover these places with their leader Hammouri, who has been looking for Mahone since two semesters already!
Hammouri will be commanding students to change their places according to the intel he receives. Each time he commands a student to change his position, he wants to know the number of places that are not covered by anyone.
Can you help these desperate students and their leader Hammouri by writing an efficient program that does the job?
Input
The first line of input contains three integers N, M and Q(2 ≤ N, M, Q ≤ 105), the number of students, the number of places, and the number of commands by Hammouri, respectively.
Students are numbered from 1 to N. Places are numbered from 1 to M.
The second line contains N integers, where the ith integer represents the location covered by the ith student initially.
Each of the following Q lines represents a command and contains two integers, A and B, where A(1 ≤ A ≤ N) is the number of a student and B(1 ≤ B ≤ M) is the number of a place. The command means student number A should go and cover place number B. It is guaranteed that B is different from the place currently covered by student A.
Changes are given in chronological order.
Output
After each command, print the number of uncovered places.
Sample Input
4 5 4
1 2 1 2
1 3
2 4
4 5
3 5
2
1
1
2 题意:n个人 m个位置 q次变化 n个人给定初始位置 ,每次变化后输出没有被覆盖的位置的个数 题解:强行stl
#include<bits/stdc++.h>
#define ll __int64
using namespace std;
int n,m,q;
vector<int> ve[];
int gg[];
int exm;
int a,b;
int main()
{
scanf("%d %d %d",&n,&m,&q);
int flag=;
for(int i=;i<=n;i++)
{
scanf("%d",&exm);
if(ve[exm].size()==)
flag++;
gg[i]=exm;
ve[exm].push_back(i);
}
for(int i=;i<=q;i++)
{
scanf("%d %d",&a,&b);
if(ve[gg[a]].size()==)
{
flag--;
}ve[gg[a]].pop_back();
if(ve[b].size()==)
flag++;
ve[b].push_back(a);
gg[a]=b;
cout<<m-flag<<endl;
} return ;
}
Gym 100989F 水&愚&vector的更多相关文章
- Gym 100971C 水&愚&三角形
Description standard input/output Announcement Statements There is a set of n segments with the le ...
- Gym 100971B 水&愚
Description standard input/output Announcement Statements A permutation of n numbers is a sequence ...
- Gym - 100989F
You must have heard about Agent Mahone! Dr. Ibrahim hired him to catch the cheaters in the Algorithm ...
- UESTC 2016 Summer Training #1 Div.2
最近意志力好飘摇..不知道坚不坚持得下去.. 这么弱还瞎纠结...可以滚了.. 水题都不会做.. LCS (A) 水 LCS (B) 没有看题 Gym 100989C 水 1D Cafeteria ( ...
- Codeforces 757C. Felicity is Coming!
C. Felicity is Coming! time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- poj1330+hdu2586 LCA离线算法
整整花了一天学习了LCA,tarjan的离线算法,就切了2个题. 第一题,给一棵树,一次查询,求LCA.2DFS+并查集,利用深度优先的特点,回溯的时候U和U的子孙的LCA是U,U和U的兄弟结点的子孙 ...
- LeetCode--第180场周赛
LeetCode--第180场周赛 1380. 矩阵中的幸运数 class Solution { public: vector<int> luckyNumbers (vector<v ...
- codeforces Gym 100187L L. Ministry of Truth 水题
L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- Codeforces gym 100685 C. Cinderella 水题
C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...
随机推荐
- Restful API 的设计规范
RESTful 是目前最流行的 API 设计规范,用于 Web 数据接口的设计.降低开发的复杂性,提高系统的可伸缩性. Restful API接口规范包括以下部分: 一.协议 API与用户的通信协议, ...
- c++ 软件下载 Dev cpp下载
下载地址: 链接: https://pan.baidu.com/s/1hsiWQPY 密码: bdpn
- VueX源码分析(3)
VueX源码分析(3) 还剩余 /module /plugins store.js /plugins/devtool.js const devtoolHook = typeof window !== ...
- build path导入的jar失效导致找不到类
今天碰到一个很奇葩的问题,搞起我以后都不敢 build path到jar了 所以我就全部放到lib目录下了,因为之前使用build path导入的jar失效了,一直找不类,具体原因我也不清楚,我之前的 ...
- 多种方式实现依赖注入及使用注解定义bean
构造注入 如何给构造方法中的参数注入方法呢如下 首先bean代码如下 package cn.pojo; public class Greeting { /** * 说的话 */ private Str ...
- 权限组件(15):rbac的使用文档和在业务中的应用
这里用主机管理系统当做示例. 一.将rbac组件拷贝到项目中. 注意: rbac自己的静态文件.layout.html(被继承的模板).bootstrap.fontsize.公共的css.jquery ...
- Tame Me【驯服我】
Tame Me “Good morning,” said the fox. 早上好,狐狸说 “Good morming,” the little prince responded politely,a ...
- 【Isamaru, Hound of Honda】SVN常用命令补遗
一些常用的 就是svn commit的时候 都必须是最新版本的东西 不能不是,但是其实只是.svn在控制,所以可以update到最新版本再svn merge -r 20:10 将版本10和20的融合, ...
- HDU 6228 tree 简单思维树dp
一.前言 前两天沈阳重现,经过队友提点,得到3题的成绩,但是看到这题下意识觉得题目错了,最后发现实际上是题目读错了....GG 感觉自己前所未有的愚蠢了....不过题目读对了也是一道思维题,但是很好理 ...
- 笔记-HTTP代理
笔记-HTTP代理 1. 基本原理 所谓代理,一个重要的目的是身份伪装,让被访问端无法正辨识访问者的身份. 那么下一个问题是服务器从哪些信息上来识别访问端的身份. 以php http服务器为 ...