QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#797804#9802. Light Up the GridDLYdly1105WA 26ms12544kbC++141.9kb2024-12-03 18:46:472024-12-03 18:46:48

Judging History

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

  • [2024-12-03 18:46:48]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:12544kb
  • [2024-12-03 18:46:47]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,a[10]={1,2,4,8,3,12,5,10,15},b[10];
int f[100][100],dp[(1<<16)+10][16],ans[(1<<16)+10];
void init()
{
    for(int i=0;i<16;i++)
    {
        for(int j=0;j<16;j++)f[i][j]=1e18;
        f[i][i]=0;
    }
    for(int i=0;i<16;i++)
    {
        for(int j=0;j<=8;j++)
        {
            f[i][i^a[j]]=min(f[i][i^a[j]],b[j]);
        }
    }
    for(int k=0;k<16;k++)
    {
        for(int i=0;i<16;i++)
        {
            for(int j=0;j<16;j++)
            {
                f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
            }
        }
    }
    for(int i=1;i<(1<<16);i++)
    {
        for(int j=0;j<16;j++)dp[i][j]=1e18;
        ans[i]=1e18;
    }
    dp[(1<<15)][15]=min(b[0],min(b[4],min(b[6],b[8])))*2;
    ans[(1<<15)]=dp[(1<<15)][15];
    for(int i=1;i<(1<<16);i++)
    {
        for(int j=0;j<16;j++)
        {
            if((i&(1<<j)))
            {
                for(int k=0;k<16;k++)
                {
                    if(j!=k&&((i&(1<<k))))
                    {
                        dp[i][j]=min(dp[i][j],dp[i-(1<<j)][k]+f[k][j]);
                    }
                }
                if(i==(1<<j))dp[i][j]=f[15][j];
                ans[i]=min(ans[i],dp[i][j]);
            }
        }
    }
    return;
}
signed main()
{
    scanf("%lld%lld%lld%lld%lld",&T,&b[0],&b[4],&b[6],&b[8]);
    b[1]=b[0];
    b[2]=b[0];
    b[3]=b[0];
    b[5]=b[4];
    b[7]=b[6];
    init();
    while(T--)
    {
        int m,id=0;
        string str;
        scanf("%lld",&m);
        for(int i=1;i<=m;i++)
        {
            int x=0;
            cin>>str;
            x=(str[0]-'0')*8+(str[1]-'0')*4;
            cin>>str;
            x+=(str[0]-'0')*2+(str[1]-'0');
            id|=(1<<x);
        }
        printf("%lld\n",ans[id]);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 26ms
memory: 12544kb

input:

2 1000 100 10 1
4
10
00

01
00

00
10

00
01
1
11
11

output:

1121
0

result:

wrong answer 2nd numbers differ - expected: '2', found: '0'