結果

問題 No.670 log は定数
ユーザー heyshbheyshb
提出日時 2018-03-26 20:21:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,988 ms / 4,000 ms
コード長 1,024 bytes
コンパイル時間 1,140 ms
コンパイル使用メモリ 147,132 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 13:11:33
合計ジャッジ時間 32,544 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,988 ms
4,380 KB
testcase_01 AC 2,751 ms
4,380 KB
testcase_02 AC 2,888 ms
4,380 KB
testcase_03 AC 2,711 ms
4,376 KB
testcase_04 AC 2,872 ms
4,376 KB
testcase_05 AC 2,611 ms
4,376 KB
testcase_06 AC 2,728 ms
4,384 KB
testcase_07 AC 2,962 ms
4,380 KB
testcase_08 AC 2,681 ms
4,376 KB
testcase_09 AC 2,652 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

ull seed;
int next() {
    seed = seed ^ (seed << 13);
    seed = seed ^ (seed >> 7);
    seed = seed ^ (seed << 17);
    return (seed >> 33);
}

int a[200010];

int main() {
    int n, q;
    cin >> n >> q >> seed;
    for (int i = 0; i < 10000; i++) next();
    for (int i = 1; i <= n; i++) a[i] = next();
    sort(a + 1, a + n + 1);

    ll sm = 0;
    ll del = 0;
    int maki = 16;
    int nico = 4;
    for (int i = 0; i < q; i++) {
        int x = next();
        int y = (1ll * x * n) >> 31;
        while (y > maki && a[y-maki] >= x) y-=maki;
        while (y + maki < n && a[y+maki] < x) y+=maki;
        while (y > nico && a[y-nico] >= x) y-=nico;
        while (y + nico < n && a[y+nico] < x) y+=nico;
        while (y > 0 && a[y] >= x) y--;
        while (y < n && a[y+1] < x) y++;
        sm ^= ll(y) * i;
    }
    cout << sm << endl;
    //cout << del << ' ' << q << ' ' << del / q << endl;
    return 0;
}
0