QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#320801 | #7932. AND-OR closure | ElTeeran_ElHayga# | WA | 1ms | 3576kb | C++20 | 2.1kb | 2024-02-03 21:34:45 | 2024-02-03 21:34:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define fi first
#define se second
#define pp push_back
#define all(x) (x).begin(), (x).end()
#define Ones(n) __builtin_popcount(n)
#define endl '\n'
#define mem(arrr, xx) memset(arrr,xx,sizeof arrr)
//#define int long long
#define debug(x) cout << (#x) << " = " << x << endl
void Gamal() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef Clion
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}
int dx[] = {+0, +0, -1, +1, +1, +1, -1, -1};
int dy[] = {-1, +1, +0, +0, +1, -1, +1, -1};
const double EPS = 1e-9;
const ll OO = 0X3F3F3F3F3F3F3F3F;
const int N = 2e5 + 5, INF = INT_MAX, MOD = 1e9 + 7, LOG = 20;
struct Basis {
vector<ll> basis;
int LOG, sz;
Basis(int log = 61) {
LOG = log;
sz = 0;
basis.resize(LOG);
}
bool insert(ll x) {
for (int i = LOG - 1; i >= 0; --i) {
if (x >> i & 1 ^ 1)continue;
if (basis[i]) {
x ^= basis[i];
} else {
basis[i] = x;
sz++;
return true;
}
}
return false;
}
ll getMax(ll x = 0) {
ll ret = x;
for (int i = LOG - 1; i >= 0; --i) {
ret = max(ret, ret ^ basis[i]);
}
return ret;
}
};
void solve() {
int n;
cin >> n;
vector<ll> v(n);
ll x = -1;
bool zero = false;
for (int i = 0; i < n; ++i) {
cin >> v[i];
if (v[i])x &= v[i];
zero |= v[i] == 0;
}
Basis bs;
for (int i = 0; i < n; ++i) {
if (!v[i])continue;
bs.insert(v[i] ^ x);
}
ll ans = 1;
for (int i = 0; i < bs.sz; ++i) {
ans *= 2;
}
if (!zero && (x || n == bs.sz))ans--;
if (x)ans++;
cout << ans;
}
signed main() {
Gamal();
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3576kb
input:
4 0 1 3 5
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
5 0 1 2 3 4
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3572kb
input:
49 1097363587067 1096810445814 275012137504 1096739142630 1096809921522 1087071335264 829364908576 949625500192 1087142638448 1096200190829 1097292808175 1095750860656 1087144145776 1097346808827 1095734082416 1096755396578 829230678048 1095663303524 1087072842592 1096216444777 949623992864 10962714...
output:
2048
result:
wrong answer 1st numbers differ - expected: '52', found: '2048'