QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#649123 | #8332. Two in One | lyx123886a123886 | RE | 0ms | 0kb | C++14 | 1.3kb | 2024-10-17 21:44:22 | 2024-10-17 21:44:23 |
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dec(i,a,b) for(int i=(a);i>=(b);--i)
using ll=long long;
using pi=pair<int,int>;
using vi=vector<int>;
using vp=vector<pi>;
template<class T> bool chkmin(T &x,T y) {return (y<x)?(x=y,true):false;}
template<class T> bool chkmax(T &x,T y) {return (y>x)?(x=y,true):false;}
#define pb push_back
#define SZ(x) int(x.size())
#define LOCAL 1
#define open_file if(LOCAL) {freopen("qoj.in","r",stdin);freopen("qoj.out","w",stdout);}
#define bit(s,i) (((s)>>(i))&1)
#define Bit(i) (1<<(i))
const int MAXN=1e5+60;
int occ[MAXN],n,a[MAXN],X,Y,OX,OY;//occ(X)>=occ(Y)>=occ(else)
void solve() {
scanf("%d",&n);memset(occ,0,sizeof(int)*(n+1));
rep(i,1,n) scanf("%d",a+i),occ[a[i]]++;
X=Y=-1;OX=0,OY=0;
rep(i,1,n) if(chkmax(OY,occ[i])) {
Y=i;
if(OY>OX) swap(X,Y),swap(OX,OY);
}
if(Y==-1) {//same
printf("%d\n",n);
return ;
}
int p=20;
while((~p)&&(!bit(OX,p)||!bit(OY,p))) p--;
int ret=0;
rep(i,0,p) ret|=Bit(i);
rep(i,p+1,20) ret|=(bit(OX,i)^bit(OY,i))<<i;
printf("%d\n",ret);
}
int main() {
open_file
int test_case;scanf("%d",&test_case);
for(;test_case;test_case--) {
solve() ;
}
return 0;
}
詳細信息
Test #1:
score: 0
Dangerous Syscalls
input:
1 7 1 2 3 4 3 2 1