QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#463197#8332. Two in OnePlentyOfPenalty#WA 0ms3736kbC++20816b2024-07-04 15:22:132024-07-04 15:22:13

Judging History

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

  • [2024-07-04 15:22:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3736kb
  • [2024-07-04 15:22:13]
  • 提交

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'