QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#346890 | #7932. AND-OR closure | kevinshan# | WA | 1ms | 3828kb | C++17 | 838b | 2024-03-09 05:12:09 | 2024-03-09 05:12:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e5 + 10;
int a[maxn], n;
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
if (fopen("input.in", "r")) {
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
}
int mx = 0, mn = LLONG_MAX, f = 0;
cin>>n;
for (int i=1; i<=n; i++) cin>>a[i], mx |= a[i], mn &= a[i], f |= (a[i] == 0);
if (n == 1) return cout<<0, 0;
int range = mx - mn + 1 + f;
//ans = range - 1l<<(basis.size())
int bmx = log2(mx), bmn = mn > 0 ? log2(mn) : 0, cnt = 0;
for (int i=bmn; i<=bmx; i++)
{
int cur = LLONG_MAX;
for (int j=1; j<=n; j++) if (a[j] >> i & 1) cur &= a[j];
if (cur != (1ll<<i)) cnt++;
}
cout<<range-(1ll<<cnt);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3828kb
input:
4 0 1 3 5
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
5 0 1 2 3 4
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3632kb
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:
822486204380
result:
wrong answer 1st numbers differ - expected: '52', found: '822486204380'