Pagini recente » Cod sursa (job #36353) | Cod sursa (job #2535367) | Cod sursa (job #1628435) | Cod sursa (job #2669241) | Cod sursa (job #2193033)
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String args[]) throws IOException {
HashSet<Integer> valuesSet = new HashSet<Integer>();
int n;
List<String> outData = new ArrayList<String>();
try {
File file = new File("hashuri.in");
Scanner scanner = new Scanner(file);
n = scanner.nextInt();
for (int i = 0; i < n; i++) {
int operation = scanner.nextInt();
int parameter = scanner.nextInt();
if (operation == 1) {
valuesSet.add(parameter);
}
if (operation == 2) {
valuesSet.remove(parameter);
}
if (operation == 3) {
if (valuesSet.contains(parameter)) {
outData.add("1");
} else {
outData.add("0");
}
}
}
Path out = Paths.get("hashuri.out");
Files.write(out, outData, Charset.defaultCharset());
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}