結果
問題 | No.206 数の積集合を求めるクエリ |
ユーザー | Grenache |
提出日時 | 2015-06-08 15:12:51 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,147 bytes |
コンパイル時間 | 3,217 ms |
コンパイル使用メモリ | 77,932 KB |
実行使用メモリ | 59,484 KB |
最終ジャッジ日時 | 2024-07-06 14:46:17 |
合計ジャッジ時間 | 11,748 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
37,164 KB |
testcase_01 | AC | 40 ms
37,328 KB |
testcase_02 | AC | 40 ms
37,296 KB |
testcase_03 | AC | 41 ms
37,160 KB |
testcase_04 | AC | 40 ms
37,328 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 42 ms
37,176 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 102 ms
40,428 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 130 ms
40,176 KB |
testcase_21 | WA | - |
testcase_22 | AC | 160 ms
40,664 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.InputMismatchException; public class Main_yukicoder206 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int l = sc.nextInt(); int m = sc.nextInt(); int n = sc.nextInt(); long[] a = new long[(2 * n + 63) / 64]; long[] b = new long[(2 * n + 63) / 64]; for (int i = 0; i < l; i++) { setBit(a, sc.nextInt() - 1); } for (int i = 0; i < m; i++) { setBit(b, sc.nextInt() - 1); } int q = sc.nextInt(); for (int i = 0; i < q; i++) { pr.println(countBit(a, b)); shiftBit(b); } pr.close(); sc.close(); } private static void shiftBit(long[] b) { boolean carry = false; for (int i = 0; i < b.length; i++) { boolean tmp = (b[i] & 0x80000000) != 0; b[i] <<= 1; if (carry) { b[i] |= 0x1; } carry = tmp; } } private static int countBit(long[] a, long[] b) { int ret = 0; for (int i = 0; i < a.length; i++) { long tmp = a[i] & b[i]; ret += Long.bitCount(tmp); } return ret; } private static void setBit(long[] a, int i) { int n = i / 64; long mask = 0x1 << (i % 64); a[n] |= mask; } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; StreamTokenizer st; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); st = new StreamTokenizer(br); } String next() throws RuntimeException { try { if (st.nextToken() != StreamTokenizer.TT_WORD) { throw new InputMismatchException(); } return st.sval; } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { try { if (st.nextToken() != StreamTokenizer.TT_NUMBER) { throw new InputMismatchException(); } return (int)st.nval; } catch (IOException e) { throw new IllegalStateException(); } } long nextLong() throws RuntimeException { try { if (st.nextToken() != StreamTokenizer.TT_NUMBER) { throw new InputMismatchException(); } return (long)st.nval; } catch (IOException e) { throw new IllegalStateException(); } } float nextFloat() throws RuntimeException { try { if (st.nextToken() != StreamTokenizer.TT_NUMBER) { throw new InputMismatchException(); } return (float)st.nval; } catch (IOException e) { throw new IllegalStateException(); } } double nextDouble() throws RuntimeException { try { if (st.nextToken() != StreamTokenizer.TT_NUMBER) { throw new InputMismatchException(); } return st.nval; } catch (IOException e) { throw new IllegalStateException(); } } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }