QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#134837 | #6631. Maximum Bitwise OR | Team_name# | WA | 26ms | 3704kb | C++20 | 886b | 2023-08-05 09:13:01 | 2023-08-05 09:13:02 |
Judging History
answer
#include <bits/stdc++.h>
#define _debugVar(x) { cerr << #x << " = " << x << endl; }
using namespace std;
using LL = long long;
const int N = 1e5+5;
int n, m;
int a[N];
int s[N][31];
int main()
{
// freopen("1.in", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while(T--) {
cin >> n >> m;
for(int i = 1; i <= n; i++) {
cin >> a[i];
for(int j = 30; j >= 0; j--) {
s[i][j] = s[i-1][j]+((a[i]>>j)&1);
}
}
while(m--) {
int l, r;
cin >> l >> r;
LL ans = 0;
int maxbit = -1;
for(int j = 30; j >= 0; j--) {
if(maxbit == -1 && s[r][j]-s[l-1][j]) {
maxbit = j;
break;
}
}
int cnt = 0;
for(int j = maxbit; j >= 0; j--) {
ans += (1<<j);
if(s[r][j]-s[l-1][j] == 0) cnt++;
}
printf("%lld %d\n", ans, cnt);
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3704kb
input:
1 3 2 10 10 5 1 2 1 3
output:
15 2 15 0
result:
ok 4 number(s): "15 2 15 0"
Test #2:
score: -100
Wrong Answer
time: 26ms
memory: 3696kb
input:
100000 1 1 924704060 1 1 1 1 149840457 1 1 1 1 515267304 1 1 1 1 635378394 1 1 1 1 416239424 1 1 1 1 960156404 1 1 1 1 431278082 1 1 1 1 629009153 1 1 1 1 140374311 1 1 1 1 245014761 1 1 1 1 445512399 1 1 1 1 43894730 1 1 1 1 129731646 1 1 1 1 711065534 1 1 1 1 322643984 1 1 1 1 482420443 1 1 1 1 20...
output:
1073741823 11 268435455 15 536870911 12 1073741823 12 536870911 15 1073741823 13 536870911 18 1073741823 14 268435455 13 268435455 14 536870911 10 67108863 11 134217727 10 1073741823 10 536870911 18 536870911 14 268435455 13 536870911 9 536870911 10 536870911 12 268435455 18 268435455 10 1073741823 ...
result:
wrong answer 2nd numbers differ - expected: '2', found: '11'