Pagini recente » Cod sursa (job #478915) | Cod sursa (job #2354135) | Cod sursa (job #1325034) | Cod sursa (job #45310) | Cod sursa (job #1862332)
import java.util.*;
import java.io.*;
public class Main {
public static Map<Integer,Integer> h = new HashMap<Integer,Integer>();
public static void add (int x)
{
h.put(calculateKey(x),x);
}
public static void delete( int x)
{
h.remove(calculateKey(x));
}
public static int calculateKey(int element)
{
return element%666013;
}
public static void main(String[] args) throws IOException
{
Scanner in = new Scanner(new FileInputStream("hashuri.in"));
PrintWriter out = new PrintWriter("hashuri.out");
int n = in.nextInt();
for(int i=1; i<=n;++i)
{
int op = in.nextInt();
int x = in.nextInt();
if (op == 1)
add(x);
else if (op == 2)
delete(x);
else
{
boolean b = h.containsValue(x);
int v = b? 1:0;
out.println(v);
}
}
out.close();
in.close();
}
}