UESTC Summer Training #1 Div.2 f-mission in Amman (A) Dynamic maintenance (refresh:--、 + +)

Source: Internet
Author: User

F-Mission in Amman (A)Time limit:MS Memory Limit:262144KB 64bit IO Format:%i64d &%i64u SubmitStatusPracticeGym 100989F

Description

Standard Input/output

You must has 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 are in order to take revenge!

Agent Mahone is planning-visit Amman this weekend. During His visit, there is M places where he might appear. The N

Students is trying to cover these places with their leader Hammouri, who have been looking for Mahone since

already!

Hammouri'll is commanding students to change their places according to the Intel he receives. Each time he commands a

Student to position, he wants to know the number of places, is not covered by anyone.

Can these desperate students and their leader Hammouri by writing a 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 is numbered from 1 to N. Places is numbered from 1 to M.

The second line contains N integers, where the ith integer represents the location cov Ered by the ith student initially.

Each of the following Q lines represents a command and contains the integers, a and B, WH ere 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 this B is different from the place currently covered by student A.

Changes is given in chronological order.

Output

After each command, print the number of uncovered places.

Sample Input

Input
4 5 41 2 1 21 32 44 53 5
Output
2112

Source

Http://acm.hust.edu.cn/vjudge/contest/view.action?cid=121539#problem/F


My Solution

The whole process first, then the side input operation, side maintenance, when + +, when--

So direct running side maintenance, quite common, codeforces seen several times ^_^



Thank you!

------ from Prolights

UESTC Summer Training #1 Div.2 f-mission in Amman (A) Dynamic maintenance (refresh:--、 + +)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.