5671: 在线会议

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

B. 在线会议
每次测试的时间限制
1 秒
每个测试的内存限制
256 兆字节
输入
标准输入
输出
标准输出
F公司的几乎每个项目都有一个完整的开发团队在工作。他们经常在不同的城市甚至国家的办公室的不同房间。为了保持联系并跟踪项目的结果,F公司在Spyke聊天中进行共享的在线会议。
有一天,F公司的董事掌握了一个成功团队在线会议的一部分记录。导演看了记录,想和组长谈谈。但是他怎么知道领导者是谁呢?从逻辑上讲,主管假定领导者是在聊天会议期间出席任何对话的人。换句话说,如果在某个时刻至少有一个人出席会议,那么领导者就会出席会议。
你是副导演。按时间顺序给定会议的“用户已登录”/“用户已注销”消息,帮助主管确定谁可以成为领导者。请注意,主管只有会议的连续部分的记录(可能不是整个会议)。

输入
第一行包含整数 n 和 m (1≤nm≤105 - 团队参与者的数量和消息的数量。接下来的 m 行中的每一行都包含以下格式的消息:
  • 'id':记录表示号码 ID 为 (1≤idn 的人员已登录到会议。
  • 'id':记录表示号码 ID (1≤idn 的人员已从会议注销。
假设团队中的所有人员都从 1 到 n 编号,消息按时间顺序给出。保证给定的顺序是会议连续部分的正确记录。保证不会同时发生两个登录/注销事件。
输出
在第一行打印整数 k (0≤kn − 有多少人可以成为领导者。在下一行中,按递增顺序打印 k 个整数 - 可以成为领导者的人数。
如果数据使得团队中没有成员可以成为领导者,请打印单个数字 0

例子
输入
5 4
+ 1
+ 2
- 2
- 1
输出
4
1 3 4 5 
输入
3 2
+ 1
- 2
输出
1
3 
输入
2 4
+ 1
- 1
+ 2
- 2
输出
0
输入
5 6
+ 1
- 1
- 3
+ 3
+ 4
- 4
输出
3
2 3 5 
输入
2 4
+ 1
- 2
+ 2
- 1
输出
0
B. Online Meeting
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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).

Input
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≤idn) has logged on to the meeting.
  • '- id': the record means that the person with number id (1≤idn) 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.
Output
In the first line print integer k (0≤kn) − 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.

Examples
Input
5 4
+ 1
+ 2
- 2
- 1
Output
4
1 3 4 5 
Input
3 2
+ 1
- 2
Output
1
3 
Input
2 4
+ 1
- 1
+ 2
- 2
Output
0
Input
5 6
+ 1
- 1
- 3
+ 3
+ 4
- 4
Output
3
2 3 5 
Input
2 4
+ 1
- 2
+ 2
- 1
Output
0

输入样例 复制


输出样例 复制