結果
問題 | No.2195 AND Set |
ユーザー | Asahi |
提出日時 | 2023-01-21 01:57:52 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,809 bytes |
コンパイル時間 | 2,395 ms |
コンパイル使用メモリ | 75,352 KB |
実行使用メモリ | 84,788 KB |
最終ジャッジ日時 | 2023-09-05 18:02:18 |
合計ジャッジ時間 | 29,004 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 121 ms
55,940 KB |
testcase_01 | AC | 124 ms
56,108 KB |
testcase_02 | AC | 1,896 ms
70,472 KB |
testcase_03 | AC | 1,943 ms
73,076 KB |
testcase_04 | AC | 1,609 ms
65,884 KB |
testcase_05 | AC | 1,937 ms
78,476 KB |
testcase_06 | AC | 1,980 ms
72,520 KB |
testcase_07 | AC | 1,639 ms
72,392 KB |
testcase_08 | AC | 1,873 ms
71,884 KB |
testcase_09 | AC | 1,523 ms
71,968 KB |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | AC | 1,997 ms
80,312 KB |
testcase_14 | TLE | - |
ソースコード
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(); } }