QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#500745#6545. Connect the Dotscocoa_chan#WA 1ms7964kbC++171.9kb2024-08-01 19:33:192024-08-01 19:33:19

Judging History

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

  • [2024-08-01 19:33:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7964kb
  • [2024-08-01 19:33:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,m,i,j,k,l,r,x,y,z,w,s,t,a[1100000],dp[1100000],prv[1100000],e,ee;
ll possible(ll x,ll y)
{
    ll i;
    for(i=x;i<y;i++)
    {
        if(a[i]==a[i+1])
            return 0;
    }
    if(a[x]==a[y])
        return 0;
    return 1;
}
void asdf(ll x,ll y)
{
    ll i;
    for(i=x;i<y;i++)
        printf("%lld %lld\n",i,i+1);
    printf("%lld %lld\n",y,x);
}
int main()
{
    scanf("%lld",&e);
    for(ee=0;ee<e;ee++)
    {
        scanf("%lld %lld",&n,&m);
        for(i=1;i<=n;i++)
        {
            scanf("%lld",&a[i]);
        }
        x=0;
        for(i=2;i<=n;i++)
        {
            if(a[i]!=a[1])
            {
                x=1;
                break;
            }
        }
        if(x==0)
        {
            printf("0\n");
            continue;
        }
        dp[0]=1;
        for(i=1;i<=n;i++)
        {
            dp[i]=0;
            prv[i]=0;
        }
        for(i=1;i<=n;i++)
        {
            for(j=2;j<=10;j++)
            {
                if(i-j<0)
                    continue;
                if(possible(i-j+1,i)&&dp[i-j]==1)
                    {
                        dp[i]=1;
                        prv[i]=i-j;
                    }
            }
        }
        if(dp[n])
        {
            printf("%lld\n",n);
            x=n;
            while(x)
            {
                asdf(prv[x]+1,x);
                x=prv[x];
            }
            continue;
        }
        printf("%lld\n",n-1);
        x=a[1];
        for(i=1;i<=n;i++)
        {
            if(x!=a[i])
            {
                printf("%lld %lld\n",ll(1),i);
                for(j=i;j>=2;j--)
                {
                    if(a[j]!=x)
                        break;
                    printf("%lld %lld\n",j,i);
                }
            }
        }
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7964kb

input:

3
4 2
1 1 2 2
4 2
1 2 1 2
3 3
1 2 3

output:

3
1 3
1 4
4
1 2
2 3
3 4
4 1
3
1 2
2 3
3 1

result:

wrong answer TC #1: two identical wire.