Cod sursa(job #1588818)

Utilizator LuurAndrei Florea Luur Data 3 februarie 2016 17:07:26
Problema Hashuri Scor 0
Compilator java Status done
Runda Arhiva educationala Marime 0.95 kb

import java.io.*;
import java.util.Scanner;
import java.util.Vector;

public class Main {
	public static int h(long x){
		return (int)(x % 32);
	}
    public static void main(String args[]) throws FileNotFoundException{
       Scanner input = new Scanner( new FileInputStream("g.in"));
       PrintWriter writer = new PrintWriter("g.out");
       Vector<Long>[] v = (Vector<Long>[]) new Vector[393242];
       for(int i = 0; i < v.length; i++)
          v[i] = new Vector<Long>();
 
       for(int N = input.nextInt(); N > 0; --N){
    	   int x = input.nextShort();
    	   long y = input.nextLong();
    	   if (x == 1){
    		   if (!v[h(y)].contains(y)) v[h(y)].add(y);
    	   }
    	   if (x == 2){
    		   if (v[h(y)].contains(y)) v[h(y)].removeElement(y);
    	   }
    	   if (x == 3){
    		   writer.write(String.valueOf(v[h(y)].contains(y) ? 1 :0) + "\n");
    	   }
       }
       input.close();
       writer.close();
    }
}