結果

問題 No.911 ラッキーソート
ユーザー normanorma
提出日時 2019-10-18 23:48:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,449 bytes
コンパイル時間 1,545 ms
コンパイル使用メモリ 169,004 KB
実行使用メモリ 5,316 KB
最終ジャッジ日時 2023-09-08 02:54:57
合計ジャッジ時間 4,815 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 41 ms
4,728 KB
testcase_15 AC 39 ms
4,516 KB
testcase_16 AC 41 ms
4,584 KB
testcase_17 AC 41 ms
4,592 KB
testcase_18 WA -
testcase_19 AC 40 ms
4,676 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 36 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 17 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,380 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 1 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 40 ms
4,684 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 40 ms
4,668 KB
testcase_45 AC 40 ms
4,524 KB
testcase_46 AC 41 ms
4,580 KB
testcase_47 AC 40 ms
4,772 KB
testcase_48 AC 39 ms
4,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main(int, char**)’ 内:
main.cpp:98:51: 警告: ‘d’ may be used uninitialized [-Wmaybe-uninitialized]
   98 |         int ans = (R - mask) / d - (L - 1 - mask) / d;
      |                                    ~~~~~~~~~~~~~~~^~~
main.cpp:90:13: 備考: ‘d’ はここで定義されています
   90 |         int d;
      |             ^

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	using B = bitset<62>;
	int N; cin >> N;
	int L, R; cin >> L >> R;

	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }

	int mask = 0;
	rep(i, 0, N - 1) {
		dump(B(A[i] ^   mask));
		dump(B(mask^A[i + 1]));
		if ((A[i] ^ mask) < (mask^A[i + 1]))continue;
		int y = A[i] ^ A[i + 1];
		rrep(j, 0, 63) {
			if ((y >> j) & 1) {
				mask ^= 1ll << j;
				break;
			}
		}
		dump(B(mask));
	}
	rep(i, 0, N) {
		A[i] ^= mask;
	}
	bool f = true;
	rep(i, 0, N - 1) {
		if (A[i] > A[i + 1])f = false;
	}

	if (not f) {
		cout << 0 << endl;
		return 0;
	}



	int d;
	rrep(i, 0, 63) {
		if ((mask >> i) & 1) {
			d = 1ll << (i + 1);
			break;
		}
	}

	int ans = (R - mask) / d - (L - 1 - mask) / d;

	cout << ans << endl;



	return 0;
}
0