QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554868 | #8332. Two in One | hxhhxh | WA | 0ms | 3880kb | C++14 | 712b | 2024-09-09 16:48:29 | 2024-09-09 16:48:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],p,q,ans,c[100005];
void doing(){
scanf("%d",&n);
for(int i=1;i<=n;i++) c[i]=0;
for(int i=1;i<=n;i++) scanf("%d",&a[i]),c[a[i]]++;
p=1;
for(int i=2;i<=n;i++) if(c[i]>c[p]) p=i;
q=p,ans=c[p];
for(int i=1;i<=n;i++){
if(i==p) continue;
int a=c[i],b=c[p],o=a&b,d=o?(1<<__lg(o))-1:0;
if(ans<(a|b|d)) ans=a|b|d,q=i;
}
for(int i=1,j=0,k=0;i<=n;i++){
if(a[i]==p) j++;
if(a[i]==q) k++;
if((j|k)==ans){
// printf("%d\n",ans);
printf("%d\n%d %d\n%d %d\n",ans,1,i,p,q);
return;
}
}
printf("%d\n%d %d\n%d %d\n",ans,1,n,p,q);
// printf("NO qwq\n");
}
int main(){
int T;
cin>>T;
while(T--) doing();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3880kb
input:
1 7 1 2 3 4 3 2 1
output:
3 1 6 1 2
result:
wrong answer Output contains longer sequence [length = 5], but answer contains 1 elements