#P3998. [SHOI2013] 发微博
[SHOI2013] 发微博
Description
The newly launched SH Weibo has users (labeled ). During this brief month, users were very active, and there are records in chronological order:
! x 表示用户 x 发了一条微博;
+ x y 表示用户 x 和用户 y 成为了好友
− x y 表示用户 x 和用户 y 解除了好友关系
When a user posts a Weibo, all of their friends (direct connections) will see the message.
Assume that initially no one is friends with anyone else, and all records are valid (i.e., when + x y occurs, and are not friends; when − x y occurs, and are friends).
After these records, determine how many messages each user has seen.
Input Format
The first line contains two integers , .
The next lines contain the records in chronological order, each formatted as described above and separated by spaces.
Output Format
Output one line with space-separated integers (no trailing space). The -th number denotes the number of messages seen by user .
2 8
! 1
! 2
+ 1 2
! 1
! 2
- 1 2
! 1
! 2
1 1
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号