QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770475#9541. Expanding ArrayJEdwardWA 0ms3608kbC++20947b2024-11-21 22:02:272024-11-21 22:02:29

Judging History

你现在查看的是最新测评结果

  • [2024-11-21 22:02:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-11-21 22:02:27]
  • 提交

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'