結果

問題 No.670 log は定数
ユーザー chocoruskchocorusk
提出日時 2018-11-04 03:19:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,862 ms / 4,000 ms
コード長 1,331 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 97,156 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 21:38:23
合計ジャッジ時間 42,301 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,838 ms
6,816 KB
testcase_01 AC 3,495 ms
6,944 KB
testcase_02 AC 3,696 ms
6,944 KB
testcase_03 AC 3,579 ms
6,940 KB
testcase_04 AC 3,808 ms
6,940 KB
testcase_05 AC 3,446 ms
6,944 KB
testcase_06 AC 3,710 ms
6,944 KB
testcase_07 AC 3,862 ms
6,944 KB
testcase_08 AC 3,788 ms
6,940 KB
testcase_09 AC 3,489 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned long long ull;

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

int main()
{
	int n, q;
	cin>>n>>q>>seed;
	for (int i = 0; i < 10000; i++) next();
    int a[200001];
    for (int i = 0; i < n; i++) a[i] = next();
	sort(a, a+n);
	ll sm=0;
	ll mx=1ll<<31;
	int d=700;
	for(int i=0; i<q; i++){
		int x=next();
		int i0=(ll)x*(ll)n/mx, i1=max(i0-d, 0), i2=min(i0+d, n-1);
		if(x<a[i1]){
		    sm^=((ll)(lower_bound(a, a+i1, x)-a)*i);
		}else if(x>=a[i2]){
		    sm^=((ll)(lower_bound(a+i2, a+n, x)-a)*i);
		}else{
		    int l=i1, r=i2;
		    while(l!=r){
		        int m=(l+r)/2;
		        if(a[m]>=x){
		            r=m;
		            if(a[m-1]<x) break;
		        }else{
		            l=m+1;
		            if(a[m+1]>=x){
		                r=m+1;
		                break;
		            }
		        }
		    }
		    sm^=((ll)r*i);
        }
	}
	cout<<sm<<endl;
	return 0;
}
0