結果
問題 | No.911 ラッキーソート |
ユーザー | 0w1 |
提出日時 | 2019-11-28 22:42:35 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,423 bytes |
コンパイル時間 | 2,261 ms |
コンパイル使用メモリ | 214,180 KB |
実行使用メモリ | 11,416 KB |
最終ジャッジ日時 | 2023-08-12 07:35:37 |
合計ジャッジ時間 | 10,796 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
11,416 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,384 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,384 KB |
testcase_05 | AC | 2 ms
4,384 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 3 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,384 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,384 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | TLE | - |
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 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int N; int64_t L, R; cin >> N >> L >> R; vector<int64_t> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } auto calc = [&](int64_t ub, bool inc) -> int64_t { vector<vector<int64_t>> dp(62, vector<int64_t>(2)); dp[0][0] = 1; for (int i = 0; i < 61; ++i) { map<int64_t, vector<int>> pfx2pos; for (int x = 0; x < N; ++x) { pfx2pos[A[x] >> 61 - i].push_back(x); } int must = -1; for (auto it : pfx2pos) { vector<int> vec; for (int x : it.second) { int v = A[x] >> 60 - i & 1; if (vec.empty() || vec.back() != v) { vec.push_back(v); } } if (2 < vec.size()) return 0; if (1 < vec.size()) { if (must == -1) must = vec[1] < vec[0]; if (must != (vec[1] < vec[0])) return 0; } } vector<int> choices; if (must == -1) choices = { 0, 1 }; else choices = { must }; for (int l = 0; l < 2; ++l) { int v = ub >> 60 - i & 1; for (int d : choices) { if (!l && v < d) continue; dp[i + 1][l | d < v] += dp[i][l]; } } } int64_t res = dp[61][1]; if (inc) res += dp[61][0]; return res; }; int64_t ans = calc(R, true) - calc(L, false); cout << ans << endl; return 0; }