CF817E.Choosing The Commander

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires.

Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be respected by warriors.

Each warrior is represented by his personality — an integer number pip_{i} . Each commander has two characteristics — his personality pjp_{j} and leadership ljl_{j} (both are integer numbers). Warrior ii respects commander jj only if ( is the bitwise excluding OR of xx and yy ).

Initially Vova's army is empty. There are three different types of events that can happen with the army:

  • 1 pi1 p_{i} — one warrior with personality pip_{i} joins Vova's army;
  • 2 pi2 p_{i} — one warrior with personality pip_{i} leaves Vova's army;
  • 3 pi li3 p_{i} l_{i} — Vova tries to hire a commander with personality pip_{i} and leadership lil_{i} .

For each event of the third type Vova wants to know how many warriors (counting only those who joined the army and haven't left yet) respect the commander he tries to hire.

输入格式

The first line contains one integer qq ( 1<=q<=1000001<=q<=100000 ) — the number of events.

Then qq lines follow. Each line describes the event:

  • 1 pi1 p_{i} ( 1<=pi<=1081<=p_{i}<=10^{8} ) — one warrior with personality pip_{i} joins Vova's army;
  • 2 pi2 p_{i} ( 1<=pi<=1081<=p_{i}<=10^{8} ) — one warrior with personality pip_{i} leaves Vova's army (it is guaranteed that there is at least one such warrior in Vova's army by this moment);
  • 3 pi li3 p_{i} l_{i} ( 1<=pi,li<=1081<=p_{i},l_{i}<=10^{8} ) — Vova tries to hire a commander with personality pip_{i} and leadership lil_{i} . There is at least one event of this type.

输出格式

For each event of the third type print one integer — the number of warriors who respect the commander Vova tries to hire in the event.

输入输出样例

  • 输入#1

    5
    1 3
    1 4
    3 6 3
    2 4
    3 6 3
    

    输出#1

    1
    0
    

说明/提示

In the example the army consists of two warriors with personalities 33 and 44 after first two events. Then Vova tries to hire a commander with personality 66 and leadership 33 , and only one warrior respects him (, and 2<3 , but , and 5>=35>=3 ). Then warrior with personality 44 leaves, and when Vova tries to hire that commander again, there are no warriors who respect him.

首页