QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706894 | #8332. Two in One | Anneliese | WA | 0ms | 4144kb | C++14 | 1.2kb | 2024-11-03 13:52:28 | 2024-11-03 13:52:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ll = long long;
const int N = 200005;
#define rep(i,a ,b ) for(int i = a ;i<=b;i++)
#define pre(i,a ,b ) for(int i = a ;i>=b;i--)
#define pb push_back
#define sc(x) scanf("%d",&x)
const int mod=1e9+9;
int hz[35];
int get(int x,int y){
int res=0;
pre(i,20,0){
int u=0,v=0;
if((x&(1<<i))){
u=1;
}
if((y&(1<<i))){
v=1;
}
if(!u&&!v)continue;
//cout<<i<<" "<<u<<" "<<v<<endl;
if(u==v){
res|=hz[i];
return res;
}
else{
res|=(1<<i);
}
}
return res;
}
int cnt[N];
void solve() {
int n;
sc(n);
rep(i,1,n)cnt[i]=0;vector<int>p[25];
rep(i,1,n){
int x;sc(x);cnt[x]++;
}
int mx=0,cmx=0;
rep(i,1,n){
int nw=0;if(!cnt[i])continue;
int x=cnt[i];
if(mx<cnt[i])mx=cnt[i];
else if(cmx<cnt[i])cmx=cnt[i];
}
if(!cmx){
printf("%d\n",mx);
}
else
printf("%d\n",get(mx,cmx));
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
hz[0]=1;
rep(i,1,20){
hz[i]=(hz[i-1]|(1<<i));
}
int t = 1;
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: 4144kb
input:
1 7 1 2 3 4 3 2 1
output:
0
result:
wrong answer 1st numbers differ - expected: '3', found: '0'