結果
問題 | No.2195 AND Set |
ユーザー |
|
提出日時 | 2023-01-21 01:57:52 |
言語 | Java (openjdk 23) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,809 bytes |
コンパイル時間 | 2,165 ms |
コンパイル使用メモリ | 79,360 KB |
実行使用メモリ | 83,188 KB |
最終ジャッジ日時 | 2024-06-23 13:31:44 |
合計ジャッジ時間 | 31,628 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 TLE * 9 |
ソースコード
import java.util.*;import java.io.*;import java.math.*;public class Main{/* 入出力 */static BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer st;static PrintWriter output = new PrintWriter(System.out);static Scanner sc = new Scanner(System.in);/* 定数 */static final int infI = Integer.MAX_VALUE;static final long infL = Long.MAX_VALUE;static final long mod = (long)1e9+7;static String yes = "Yes";static String no = "No";public static final int [] y4 = {0,1,0,-1};public static final int [] x4 = {1,0,-1,0};/* グローバル変数 *//* Main */public static void main(String[] args) throws IOException{int Q = sc.nextInt();Set<Long> SET = new HashSet<>();int [] bit = new int[30];while(Q-->0) {int type = sc.nextInt();if(type == 1) {long x = sc.nextLong();if(!SET.contains(x)){SET.add(x);for(int i=0;i<30;i++) {if(((x>>i)&1) == 1L)bit[i]++;}}}if(type == 2) {long x = sc.nextLong();if(SET.contains(x)){SET.remove(x);for(int i=0;i<30;i++) {if(((x>>i)&1) == 1L)bit[i]--;}}}if(type == 3) {long ans = 0;if(SET.size() == 0) ans = -1L;else {for(int i=0;i<30;i++) if(bit[i] == SET.size()) ans += (1<<i);}output.println(ans);}}output.flush();}}