結果
問題 | No.2061 XOR Sort |
ユーザー | shauuebbit |
提出日時 | 2022-09-06 00:09:42 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 3,765 bytes |
コンパイル時間 | 2,608 ms |
コンパイル使用メモリ | 205,348 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-05-01 01:42:42 |
合計ジャッジ時間 | 5,498 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 53 ms
6,944 KB |
testcase_15 | AC | 52 ms
6,940 KB |
testcase_16 | AC | 104 ms
6,944 KB |
testcase_17 | AC | 67 ms
6,940 KB |
testcase_18 | AC | 69 ms
6,940 KB |
testcase_19 | AC | 66 ms
6,940 KB |
testcase_20 | AC | 11 ms
6,940 KB |
testcase_21 | AC | 31 ms
6,944 KB |
testcase_22 | AC | 52 ms
6,940 KB |
testcase_23 | AC | 3 ms
6,940 KB |
testcase_24 | AC | 107 ms
6,940 KB |
testcase_25 | AC | 107 ms
6,940 KB |
testcase_26 | AC | 107 ms
6,944 KB |
testcase_27 | AC | 108 ms
6,940 KB |
testcase_28 | AC | 107 ms
6,944 KB |
testcase_29 | AC | 26 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,944 KB |
testcase_31 | AC | 5 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 2 ms
6,944 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | AC | 2 ms
6,944 KB |
testcase_40 | AC | 2 ms
6,944 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,940 KB |
testcase_43 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> template <long long mod> class ModInt { private: long long number; public: constexpr ModInt(const ModInt& x) : number(x.number) {} constexpr ModInt(const long long number = 0) : number(number) { if (number < 0 || number >= mod) this->number %= mod; if (this->number < 0) this->number += mod; } constexpr long long get() const { return number; } constexpr ModInt& operator=(const ModInt& rhs) & { number = rhs.number; return *this; } constexpr ModInt operator+() const { return ModInt(*this); } constexpr ModInt operator-() const { return ModInt(mod - number); } constexpr ModInt& operator+=(const ModInt& rhs) { number += rhs.number; if (number >= mod) number -= mod; return *this; } constexpr ModInt& operator-=(const ModInt& rhs) { number -= rhs.number; if (number < 0) number += mod; return *this; } constexpr ModInt& operator*=(const ModInt& rhs) { number *= rhs.number; if (number >= mod) number %= mod; return *this; } constexpr ModInt& operator/=(const ModInt& rhs) { (*this) *= rhs.inverse(); return *this; } constexpr ModInt inverse() const { long long a = number, m = mod, u = 1, v = 0; while (m) { long long t = a / m; a -= t * m; u -= t * v; a ^= m; m ^= a; a ^= m; u ^= v; v ^= u; u ^= v; } return ModInt(u); } constexpr ModInt& operator++() { return *this += 1; } constexpr ModInt& operator--() { return *this -= 1; } constexpr ModInt operator++(int) { ModInt ret = *this; ++(*this); return ret; } constexpr ModInt operator--(int) { ModInt ret = *this; --(*this); return ret; } constexpr ModInt operator+(const ModInt& rhs) const { return ModInt(*this) += rhs; } constexpr ModInt operator-(const ModInt& rhs) const { return ModInt(*this) -= rhs; } constexpr ModInt operator*(const ModInt& rhs) const { return ModInt(*this) *= rhs; } constexpr ModInt operator/(const ModInt& rhs) const { return ModInt(*this) /= rhs; } constexpr ModInt operator^(const long long& rhs) const { long long b = number, e = rhs, y = 1, m = mod; bool inv = e < 0; if (inv) e = -e; while (e) { if (e & 1) (y *= b) %= m; (b *= b) %= m; e >>= 1; } return (inv ? ModInt(y).inverse() : ModInt(y)); } }; template <long long mod> std::istream& operator>>(std::istream& is, ModInt<mod>& x) { long long in; is >> in; x = in; return is; } template <long long mod> std::ostream& operator<<(std::ostream& os, const ModInt<mod>& x) { os << x.get(); return os; } constexpr int MOD = 998244353; constexpr int LEN = 30; using namespace std; using mint = ModInt<MOD>; void f(int l, int r, int k, vector<int>& c, const vector<int>& a) { if (l == r) return; if (k < 0) return; if (((a[l] >> k) & 1) == ((a[r - 1] >> k) & 1)) { f(l, r, k - 1, c, a); return; } c[k] |= 1; int m = l; for (; m < r; m++) { if ((a[m] >> k) & 1) break; } f(l, m, k - 1, c, a); f(m, r, k - 1, c, a); } int main() { int N; cin >> N; vector<int> A(N, 0); for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); vector<int> c(LEN, 0); f(0, N, LEN - 1, c, A); mint ans = 1; for (int k = 0; k < LEN; k++) { ans *= c[k] + 1; } cout << ans << endl; return 0; }