結果

問題 No.911 ラッキーソート
ユーザー yuji9511yuji9511
提出日時 2019-10-18 22:44:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,488 bytes
コンパイル時間 1,464 ms
コンパイル使用メモリ 167,940 KB
実行使用メモリ 7,632 KB
最終ジャッジ日時 2023-09-08 00:43:40
合計ジャッジ時間 5,809 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lpair;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,L,R;
	cin >> N >> L >> R;
	ll A[200010];
	rep(i,0,N) cin >> A[i];
	// rep(i,0,N){
	// 	cout << bitset<16>(A[i]) << endl;
	// }
	ll pos = -1;
	rrep(bit,61,0){
		ll cnt = 0;
		rep(i,0,N){
			if((A[i]>>bit) & 1) cnt++;
		}
		if(cnt != N && cnt != 0){
			pos = bit;
			break;
		}
	}
	ll diff = (1LL<<(pos+1));
	ll ans = 0;
	rep(bit,0,(1LL<<(pos+1))){
		vector<ll> b(N);
		rep(i,0,N){
			b[i] = (A[i]^bit);
		}
		bool ok = true;
		rep(i,0,N-1){
			if(b[i] >= b[i+1]) ok = false;
		}
		if(ok){
			ll lv = L - bit;
			if(lv < 0){
				lv = 0;
			}else{
				lv = (lv + diff-1) / diff;
			}
			ll rv = R - bit;
			if(rv < 0){
				print(0);
				return 0;
			}else{
				rv /= diff;
			}
			ans += rv-lv+1;
		}

	}
	print(ans);

	// print(pos);
	// rep(i,L,R+1){
	// 	vector<ll> b(N);
	// 	rep(j,0,N){
	// 		b[j] = (A[j]^i);
	// 	}
	// 	bool ok = true;
	// 	rep(j,0,N-1){
	// 		if(b[j] >= b[j+1]) ok = false;
	// 	}
	// 	if(ok){
	// 		print(i);
	// 		printa(b, N);
	// 	}
	// }

	

}
0