QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#554755#8332. Two in OneyuanruiqiWA 0ms3632kbC++23804b2024-09-09 15:25:012024-09-09 15:25:02

Judging History

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

  • [2024-09-09 15:25:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-09-09 15:25:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
constexpr int maxn = 100000 + 10;
int a[maxn], c[maxn];
void solve()
{
    int n;
    cin >> n;
    memset(c, 0, sizeof(c[0]) * (n + 5));
    for (int i=1;i<=n;++i) cin >> a[i], ++c[a[i]];
    int x = 0, y = 0;
    for (int i=1;i<=n;++i)
        if (!x || c[i] > c[x]) y = x, x = i;
        else if (!y || c[i] > c[y]) y = i;
    int z = (c[x] & c[y]) ? (c[x] | c[y] | ((1 << 31 - __builtin_clz(c[x] & c[y])) - 1)) : (c[x] | c[y]);
    cout << z << '\n';
    int l = 1, r = n;
    while ((c[x] | c[y]) != z) --c[a[r--]];
    cout << l << ' ' << r << '\n' << x << ' ' << y << '\n';
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
7
1 2 3 4 3 2 1

output:

3
1 6
1 2

result:

wrong answer Output contains longer sequence [length = 5], but answer contains 1 elements