QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#553865#8332. Two in OneHog_Dawa_IOIWA 0ms1664kbC++141.2kb2024-09-08 21:37:082024-09-08 21:37:09

Judging History

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

  • [2024-09-08 21:37:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1664kb
  • [2024-09-08 21:37:08]
  • 提交

answer

#include<stdio.h>
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
int t,n,s[100005],ci[100005],beg[100005],end[100005];
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        for(int i=1;i<=n;i++) ci[i]=beg[i]=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&s[i]),ci[s[i]]++;
            if(!beg[s[i]]) beg[s[i]]=i;
            end[s[i]]=i;
        }
        int k1=0,k2=0;
        for(int i=1;i<=n;i++) if(ci[i]>=ci[k1]) k1=i;
        for(int i=1;i<=n;i++) if(ci[i]>=ci[k2]&&i!=k1) k2=i;
        int ans=ci[k1]|ci[k2],dq=ci[k1]&ci[k2],mi=1,nono=1,cc1=ci[k1],cc2=ci[k2];
        while(mi<=dq)
        {
            if(mi&dq) nono=mi;
            mi*=2;
        }
        int l=max(1,min(beg[k1],beg[k2])),r=max(end[k2],end[k1]);
        if((cc1|cc2)==(ans|(nono-1))){printf("%d\n%d %d\n%d %d\n",(ans|(nono-1)),l,r,k1,k2);continue;}
        while(l<=r)
        {
            if(s[l]==k1) cc1--;
            if(s[l]==k2) cc2--;
            l++;if((cc1|cc2)==(ans|(nono-1)))
            {printf("%d\n%d %d\n%d %d\n",
            (ans|(nono-1)),l,r,k1,k2);break;}
        }
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1664kb

input:

1
7
1 2 3 4 3 2 1

output:

3
3 6
3 2

result:

wrong answer Output contains longer sequence [length = 5], but answer contains 1 elements