QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554867 | #8332. Two in One | Kazemaru | WA | 1ms | 5804kb | C++14 | 563b | 2024-09-09 16:48:17 | 2024-09-09 16:48:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,j,k) for(int i=j;i<=k;++i)
#define g(i,j,k) for(int i=j;i>=k;--i)
int n,m,s,l;
const int N=2e5;
int a[N],c[N];
inline void doing(){
scanf("%lld",&n);
f(i,1,n)scanf("%lld",&a[i]),++c[a[i]];
s=l=0;
f(i,1,n){
if(c[i]>=c[s])l=s,s=i;
else if(c[i]>c[l])l=i;
}
int p,q=0;l=l?l:1;
g(i,n,1){
m=c[s]|c[l];
if(m>q)p=i,q=m;
--c[a[i]];
}
printf("%lld\n1 %lld\n%lld %lld\n",q,p,s,l);
}
signed main(){
int t;
cin>>t;
while(t--)doing();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5804kb
input:
1 7 1 2 3 4 3 2 1
output:
3 1 5 3 2
result:
wrong answer Output contains longer sequence [length = 5], but answer contains 1 elements