QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#649123#8332. Two in Onelyx123886a123886RE 0ms0kbC++141.3kb2024-10-17 21:44:222024-10-17 21:44:23

Judging History

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

  • [2024-10-17 21:44:23]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-17 21:44:22]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

1
7
1 2 3 4 3 2 1

output:


result: