QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#463197 | #8332. Two in One | PlentyOfPenalty# | WA | 0ms | 3736kb | C++20 | 816b | 2024-07-04 15:22:13 | 2024-07-04 15:22:13 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define log(...) (void(0))
#define endl '\n'
#endif
using namespace std;
const int N=1e5;
int T,n,a,cnt[N+10],mx,m2,ans;
int Calc(int x){
return (1<<(32-__builtin_clz(x)))-1;
}
int main() {
#ifdef memset0
freopen("E.in", "r", stdin);
#endif
cin.tie(0)->sync_with_stdio(0);
cin>>T;
while(T--){
cin>>n;
for(int i=1;i<=n;++i)cnt[i]=0;
for(int i=1;i<=n;++i)cin>>a,++cnt[a];
mx=m2=0;
for(int i=1;i<=n;++i){
if(cnt[i]>mx)m2=mx,mx=cnt[i];
else m2=max(m2,cnt[i]);
}
//cerr<<"MX="<<mx<<" m2="<<m2<<"\n";
if(mx==m2){
cout<<Calc(mx)<<"\n";
continue;
}
ans=0;
for(int i=1;i<=n;++i)if(mx!=cnt[i])ans=max(ans,mx|cnt[i]|Calc(mx&cnt[i]));
cout<<ans<<"\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3692kb
input:
1 7 1 2 3 4 3 2 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3736kb
input:
1 9 1 1 1 1 1 2 2 2 2
output:
1073741823
result:
wrong answer 1st numbers differ - expected: '7', found: '1073741823'