QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554755 | #8332. Two in One | yuanruiqi | WA | 0ms | 3632kb | C++23 | 804b | 2024-09-09 15:25:01 | 2024-09-09 15:25:02 |
Judging History
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