QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#942756#8332. Two in OneDiaoTianhaoWA 0ms3584kbC++14659b2025-03-19 13:31:402025-03-19 13:31:41

Judging History

This is the latest submission verdict.

  • [2025-03-19 13:31:41]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3584kb
  • [2025-03-19 13:31:40]
  • Submitted

answer

#include <bits/stdc++.h>
int calc(int a, int b) {
    int d = a | b, e = a & b;
    while(e & (e - 1))
        e &= e - 1;
    return d | std::max(e, e - 1);
}
int cnt[131072], a[131072], T, n;
int main() {
    std::cin >> T;
    while(T--) {
        std::cin >> n;
        for(int i = 1; i <= n; i++)
            cnt[i] = 0;
        for(int i = 1; i <= n; i++)
            std::cin >> a[i], cnt[a[i]]++;
        std::sort(cnt + 1, cnt + n + 1, std::greater<int>());
        int max = 0;
        for(int i = 2; i <= n; i++)
            max = std::max(max, calc(cnt[1], cnt[2]));
        std::cout << max << '\n';
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

1
7
1 2 3 4 3 2 1

output:

2

result:

wrong answer 1st numbers differ - expected: '3', found: '2'