結果
問題 | No.184 たのしい排他的論理和(HARD) |
ユーザー | polyomino_24 |
提出日時 | 2019-09-17 03:22:40 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,775 bytes |
コンパイル時間 | 1,290 ms |
コンパイル使用メモリ | 135,020 KB |
実行使用メモリ | 57,984 KB |
最終ジャッジ日時 | 2024-07-04 12:29:57 |
合計ジャッジ時間 | 10,458 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 318 ms
41,984 KB |
testcase_09 | AC | 62 ms
11,264 KB |
testcase_10 | AC | 246 ms
32,768 KB |
testcase_11 | AC | 179 ms
24,448 KB |
testcase_12 | AC | 387 ms
48,256 KB |
testcase_13 | AC | 428 ms
51,968 KB |
testcase_14 | AC | 234 ms
31,104 KB |
testcase_15 | AC | 491 ms
56,064 KB |
testcase_16 | AC | 395 ms
47,232 KB |
testcase_17 | AC | 428 ms
50,816 KB |
testcase_18 | WA | - |
testcase_19 | AC | 1 ms
5,376 KB |
testcase_20 | AC | 125 ms
57,984 KB |
testcase_21 | AC | 496 ms
57,984 KB |
testcase_22 | AC | 497 ms
57,856 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 278 ms
36,096 KB |
testcase_29 | AC | 400 ms
49,920 KB |
testcase_30 | AC | 329 ms
44,416 KB |
testcase_31 | AC | 281 ms
38,784 KB |
testcase_32 | AC | 365 ms
47,744 KB |
testcase_33 | AC | 483 ms
56,448 KB |
testcase_34 | AC | 461 ms
55,680 KB |
testcase_35 | AC | 481 ms
57,472 KB |
testcase_36 | AC | 475 ms
57,216 KB |
ソースコード
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) //#define cerr if(false) cerr #ifdef DEBUG #define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__); #else #define show(...) 42 #endif using namespace std; using ll = long long; using pii = pair<int, int>; template <typename T, typename S> ostream& operator<<(ostream& os, pair<T, S> a) { os << '(' << a.first << ',' << a.second << ')'; return os; } template <typename T> ostream& operator<<(ostream& os, vector<T> v) { for (auto x : v) os << x << ' '; return os; } void debug() { cerr << '\n'; } template <typename H, typename... T> void debug(H a, T... b) { cerr << a; if (sizeof...(b)) cerr << ", "; debug(b...); } #ifdef DEBUG template<typename T> class Vec : public vector<T>{ public: Vec(){} Vec(int n):vector<T>(n){} Vec(int n, T a):vector<T>(n,a){} T& operator[](long long n){ if(n < 0 or n >= this->size())throw out_of_range("Vec"); return this->at(n); } const T& operator[](long long n)const{ if(n < 0 or n >= this->size())throw out_of_range("Vec"); return this->at(n); } }; #define vector Vec template<typename T> ostream &operator<<(ostream &os, set<T> st) { for(auto x : st) cerr << x << ' '; return os; } template<typename T, typename S> ostream &operator<<(ostream &os, map<T, S> mp) { for(auto x : mp) cerr << x << ' '; return os; } #endif //負の数を掛けたりするとバグる template<int MOD> class Modint{ public: int a; Modint(const long long v = 0):a(v % MOD){} int getmod() const{ return MOD; } Modint operator+(const Modint rhs) const{ return Modint(*this) += rhs; } Modint operator-(const Modint rhs) const{ return Modint(*this) -= rhs; } Modint operator*(const Modint rhs) const{ return Modint(*this) *= rhs; } Modint operator/(const Modint rhs) const{ return Modint(*this) /= rhs; } Modint operator+(const long long rhs) const{ return Modint(*this) += rhs; } Modint operator-(const long long rhs) const{ return Modint(*this) -= rhs; } Modint operator*(const long long rhs) const{ return Modint(*this) *= rhs; } Modint operator/(const long long rhs) const{ return Modint(*this) /= rhs; } friend Modint operator+(const long long a, const Modint b){ return b + a; } friend Modint operator-(const long long a, const Modint b){ return -b + a; } friend Modint operator*(const long long a, const Modint b){ return b * a; } friend Modint operator/(const long long a, const Modint b){ return Modint(a) / b; } Modint &operator+=(const Modint rhs){ a += rhs.a; if(a >= MOD){ a -= MOD; } return *this; } Modint &operator-=(const Modint rhs){ if(a < rhs.a){ a += MOD; } a -= rhs.a; return *this; } Modint &operator*=(const Modint rhs){ a = (long long)a * rhs.a % MOD; return *this; } Modint &operator/=(Modint rhs){ int x = MOD - 2; while(x){ if(x % 2){ *this *= rhs; } rhs *= rhs; x /= 2; } return *this; } Modint &operator++(){ *this += 1; return *this; } Modint &operator--(){ *this -= 1; return *this; } Modint operator++(int){ Modint res = *this; ++(*this); return res; } Modint operator--(int){ Modint res = *this; --(*this); return res; } Modint &operator+=(const long long rhs){ *this += Modint(rhs); return *this; } Modint &operator-=(const long long rhs){ *this -= Modint(rhs); return *this; } Modint &operator*=(const long long rhs){ *this *= Modint(rhs); return *this; } Modint &operator/=(const long long rhs){ *this /= Modint(rhs); return *this; } Modint operator+() const{ return *this; } Modint operator-() const{ return Modint()-*this; } bool operator==(const Modint rhs) const{ return a == rhs.a; } bool operator==(const long long rhs) const{ return a == rhs; } friend bool operator==(const long long a, const Modint b){ return a == b.a; } bool operator!=(const Modint rhs) const{ return a != rhs.a; } bool operator!=(const long long rhs) const{ return a != rhs; } friend ostream &operator<<(ostream &os, const Modint x){ os << x.a; return os; } friend istream &operator>>(istream &is, Modint &x){ is >> x.a; return is; } explicit operator bool() const{ return a > 0; } bool operator!(){ return a == 0; } explicit operator int() const{ return a; } explicit operator long long() const{ return (long long) a; } friend Modint pow(Modint a, long long b){ Modint res = 1; while(b){ if(b % 2){ res *= a; } a *= a; b /= 2; } return res; } }; using mint = Modint<2>; int gauss(vector<vector<mint>>a){ int n = (int) a.size(); int m = (int) a[0].size(); for(int i = 0; i < m; i++){ for(int j = i; j < n; j++){ if(a[j][i]){ for(int k = i; k < m; k++){ swap(a[i][k], a[j][k]); } } } if(i >= n or !a[i][i])continue; mint inv = mint(1) / a[i][i]; for(int j = 0; j < n; j++){ if(j != i and a[j][i]){ mint coef = a[j][i] * inv; for(int k = i; k < m; k++){ a[j][k] = a[j][k] - coef * a[i][k]; } } } } int res = 0; for(int i = 0; i < n and i < m; i++)if(a[i][i])res++; return res; } int main(){ int n; cin >> n; vector<vector<mint>> a; a.resize(n,vector<mint>(60)); rep(i,n){ ll x; cin >> x; rep(j,60){ if(x >> j & 1){ a[i][j] = 1; } } } cout << (1LL<<gauss(a)) << endl; }