QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 256 MB 總分: 100

#18796. 수열과 쿼리 38

统计

처음에 0이 하나 포함되어있는 배열 $A$가 있다. 이때, 다음 쿼리를 수행해야 한다.

  • 1 x: $A$의 가장 뒤에 x를 추가한다.
  • 2 x: $A$에서 x를 제거한다. $A$에 x가 두 개 이상 있는 경우에는 가장 앞에 있는 하나만 제거한다. 항상 $A$에 x가 있는 쿼리만 주어진다.
  • 3: $A$에 포함된 모든 원소를 더한 값을 출력한다.
  • 4: $A$에 포함된 모든 원소를 XOR한 값을 출력한다.

입력

첫째 줄에는 쿼리의 개수 $M$이 주어진다. 둘째 줄부터 다음 $M$ 개의 줄에 쿼리가 주어진다.

출력

3번 혹은 4번 쿼리가 등장할 때마다, 답을 한 줄에 하나씩 출력한다.

Sample

Input

12
1 3
1 1
1 4
3
4
1 1
3
4
2 1
2 4
3
4

Output

8
6
9
7
4
2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.