結果
問題 |
No.3249 AND
|
ユーザー |
|
提出日時 | 2025-08-30 12:01:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,588 bytes |
コンパイル時間 | 2,917 ms |
コンパイル使用メモリ | 279,904 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-30 12:01:59 |
合計ジャッジ時間 | 5,730 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 WA * 2 |
ソースコード
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #define all(v) v.begin(), v.end() #define eb(v) emplace_back(v) #define mp(a, b) make_pair(a, b) #define pc(x) std::bitset<sizeof(x) * 8>(x).count() #define fast cin.tie(nullptr); ios_base::sync_with_stdio(false) using namespace std; using ll = long long; using ld = long double; using graph = vector<vector<int>>; using wgraph = vector<vector<pair<ll, ll>>>; constexpr ll mod = 998244353; //constexpr ll mod = 1e9 + 7; constexpr ll inf = 2e18; static void judge(bool c) { cout << (c ? "Yes" : "No") << endl; } class BinomialCoefficient { private: long long mod; std::vector<long long> fact; std::vector<long long> inv_fact; long long power(long long base, long long exp) { long long res = 1; base %= mod; while (exp > 0) { if (exp % 2 == 1) res = (res * base) % mod; base = (base * base) % mod; exp /= 2; } return res; } public: BinomialCoefficient(int n_max, long long m) : mod(m) { fact.resize(n_max + 1); inv_fact.resize(n_max + 1); fact[0] = 1; inv_fact[0] = 1; for (int i = 1; i <= n_max; ++i) { fact[i] = (fact[i - 1] * i) % mod; } inv_fact[n_max] = power(fact[n_max], mod - 2); for (int i = n_max; i > 0; --i) { inv_fact[i - 1] = (inv_fact[i] * i) % mod; } } long long com(int n, int r) { if (r < 0 || n < r) { return 0; } if (static_cast<size_t>(n) >= fact.size()) { return -1; } long long result = fact[n]; result = (result * inv_fact[r]) % mod; result = (result * inv_fact[n - r]) % mod; return result; } }; ll ppow(ll a, ll b, ll m) { ll res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res; } int n,b[200000]; int main(){ cin >> n; for(int i = 0; i < n; i++){ cin >> b[i]; } ll ans = 0; for(int bit = 0;bit < 30; bit++){ bool f = 1; for(int j = 0; j < n; j++){ int b_bit = b[j] & (1 << bit),j_bit = (j + 1) & (1 << bit); if(b_bit && !j_bit){ cout << -1 << endl; return 0; } else if(b_bit) f = 0; } if(!f) ans |= (1 << bit); } if(ans == 0){ cout << -1 << endl; } cout << ans << endl; }