CF420B.Online Meeting

普及/提高-

通过率:0%

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).

输入格式

The first line contains integers nn and mm (1<=n,m<=105)(1<=n,m<=10^{5}) — the number of team participants and the number of messages. Each of the next mm lines contains a message in the format:

  • '+ idid ': the record means that the person with number idid (1<=id<=n)(1<=id<=n) has logged on to the meeting.
  • '- idid ': the record means that the person with number idid (1<=id<=n)(1<=id<=n) has logged off from the meeting.

Assume that all the people of the team are numbered from 11 to nn 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.

输出格式

In the first line print integer kk (0<=k<=n)(0<=k<=n) — how many people can be leaders. In the next line, print kk 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 00 .

输入输出样例

  • 输入#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
    
首页