QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770475 | #9541. Expanding Array | JEdward | WA | 0ms | 3608kb | C++20 | 947b | 2024-11-21 22:02:27 | 2024-11-21 22:02:29 |
Judging History
answer
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
unordered_set<int> uniqueValues;
for (int num : a) {
uniqueValues.insert(num);
}
// To maximize the distinct values, we need to consider the closure under AND, OR, and XOR.
// For practical purposes and efficiency, we use the bitwise OR of all elements to determine the upper bound.
int bitwiseOR = 0;
for (int num : a) {
bitwiseOR |= num;
}
// The maximum number of distinct values is 2^m, where m is the number of set bits in bitwiseOR
int m = 0;
for (int i = 0; i < 31; ++i) {
if (bitwiseOR & (1 << i)) {
m++;
}
}
int answer = 1 << m;
cout << answer << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3540kb
input:
2 2 3
output:
4
result:
ok single line: '4'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3608kb
input:
2 3 4
output:
8
result:
wrong answer 1st lines differ - expected: '4', found: '8'