結果

問題 No.670 log は定数
ユーザー yosupotyosupot
提出日時 2017-09-10 17:17:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,853 ms / 4,000 ms
コード長 1,386 bytes
コンパイル時間 2,222 ms
コンパイル使用メモリ 77,772 KB
実行使用メモリ 46,232 KB
最終ジャッジ日時 2024-04-25 03:09:36
合計ジャッジ時間 22,022 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,853 ms
46,136 KB
testcase_01 AC 1,837 ms
45,780 KB
testcase_02 AC 1,778 ms
45,676 KB
testcase_03 AC 1,697 ms
46,232 KB
testcase_04 AC 1,711 ms
46,104 KB
testcase_05 AC 1,643 ms
45,896 KB
testcase_06 AC 1,734 ms
46,020 KB
testcase_07 AC 1,688 ms
45,532 KB
testcase_08 AC 1,665 ms
46,156 KB
testcase_09 AC 1,730 ms
45,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*; 
public class Main {
    static long seed;
    static int next() {
        seed = seed ^ (seed << 13);
        seed = seed ^ (seed >>> 7);
        seed = seed ^ (seed << 17);
        return (int)(seed >>> 33);
    }

    static final long B = 300000;
    static final long S = (1L<<32) / B + 1;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        seed = sc.nextLong();
        for (int i = 0; i < 10000; i++) next();

        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = next();
        Arrays.sort(a);

        long[] idx = new long[(int)B];
        int c = 0;
        for (int i = 0; i < B; i++) {
            idx[i] |= c;
            while (c < n && (int)(a[c] / S) == i) c++;
            idx[i] |= ((long)(c) << 32);
        }
        
        long sm = 0;
        for (int qc = 0; qc < q; qc++) {
            int x = next();

            int i = (int)(x / S);
            int l = (int)(idx[i] & ((1L<<32)-1)) - 1, r = (int)(idx[i] >> 32);
            while (r-l > 1) {
                int md = (l+r)/2;
                if (a[md] < x) {
                    l = md;
                } else {
                    r = md;
                }
            }

            sm ^= (long)(r) * qc;
        }
        System.out.println(sm);
    }
}
0