QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#554867#8332. Two in OneKazemaruWA 1ms5804kbC++14563b2024-09-09 16:48:172024-09-09 16:48:18

Judging History

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

  • [2024-09-09 16:48:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5804kb
  • [2024-09-09 16:48:17]
  • 提交

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