CF420B.Online Meeting
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat.
One day the director of the F company got hold of the records of a part of an online meeting of one successful team. The director watched the record and wanted to talk to the team leader. But how can he tell who the leader is? The director logically supposed that the leader is the person who is present at any conversation during a chat meeting. In other words, if at some moment of time at least one person is present on the meeting, then the leader is present on the meeting.
You are the assistant director. Given the 'user logged on'/'user logged off' messages of the meeting in the chronological order, help the director determine who can be the leader. Note that the director has the record of only a continuous part of the meeting (probably, it's not the whole meeting).
F公司几乎每个项目都由一支完整的开发团队负责。这些开发人员常常位于不同城市甚至不同国家的办公室的不同房间中。为了保持联系并跟踪项目进展,F公司通过Spyke聊天工具开展线上联合会议。
某天,F公司的总监获取了某支成功团队一次线上会议的部分录屏记录。总监观看了该录屏后,希望与团队负责人取得联系。但他该如何判断谁是负责人呢?总监进行了合理的推断:负责人是在会议期间任何时刻都在线的人。换言之,若在某一时刻会议中至少有一人在线,则此时负责人也一定在线。
你作为助理总监,现给出该会议中按时间顺序排列的“用户上线”/“用户下线”消息,请协助总监确定谁有可能是负责人。注意:总监所掌握的仅是该会议一段连续的录屏记录(很可能并非整场会议)。
输入格式
The first line contains integers n and m (1 ≤ n, m ≤ 105) — the number of team participants and the number of messages. Each of the next m lines contains a message in the format:
- '+ id': the record means that the person with number id (1 ≤ id ≤ n) has logged on to the meeting.
- '- id': the record means that the person with number id (1 ≤ id ≤ n) has logged off from the meeting.
Assume that all the people of the team are numbered from 1 to n and the messages are given in the chronological order. It is guaranteed that the given sequence is the correct record of a continuous part of the meeting. It is guaranteed that no two log on/log off events occurred simultaneously.
第一行包含两个整数 n 和 m(1≤n,m≤105)——分别表示团队参与者的数量和消息总数。接下来的 m 行中,每行包含一条消息,格式如下:
+ id:表示编号为 id(1≤id≤n)的人员已登录会议;- id:表示编号为 id(1≤id≤n)的人员已退出会议。
假设团队所有成员编号为 1 至 n,且这些消息按时间顺序给出。保证所给序列是会议某连续时间段内的正确记录。保证不存在两个登录/退出事件同时发生。
输出格式
In the first line print integer k (0 ≤ k ≤ n) — how many people can be leaders. In the next line, print k integers in the increasing order — the numbers of the people who can be leaders.
If the data is such that no member of the team can be a leader, print a single number 0.
第一行输出一个整数 k(0≤k≤n)—— 表示可以成为队长的人数。
下一行按升序输出 k 个整数 —— 表示可以成为队长的人的编号。
如果数据使得团队中没有任何成员可以成为队长,则仅输出一个数字 0。
输入输出样例
输入#1
5 4 + 1 + 2 - 2 - 1
输出#1
4 1 3 4 5
输入#2
3 2 + 1 - 2
输出#2
1 3
输入#3
2 4 + 1 - 1 + 2 - 2
输出#3
0
输入#4
5 6 + 1 - 1 - 3 + 3 + 4 - 4
输出#4
3 2 3 5
输入#5
2 4 + 1 - 2 + 2 - 1
输出#5
0
输入解题思路,AI测评打分。不知道怎么写?