QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#797799 | #9802. Light Up the Grid | DLYdly1105 | WA | 49ms | 4352kb | C++14 | 1.7kb | 2024-12-03 18:39:34 | 2024-12-03 18:39:34 |
Judging History
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];
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++)dp[i]=1e18;
dp[(1<<15)]=min(b[0],min(b[4],min(b[6],b[8])))*2;
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]=min(dp[i],dp[i-(1<<j)]+f[k][j]);
}
}
}
if(i==(1<<j)&&j!=15)dp[i]=f[15][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",dp[id]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 30ms
memory: 4352kb
input:
2 1000 100 10 1 4 10 00 01 00 00 10 00 01 1 11 11
output:
1121 2
result:
ok 2 number(s): "1121 2"
Test #2:
score: 0
Accepted
time: 30ms
memory: 4352kb
input:
2 1 1 1 1 4 10 00 01 00 00 10 00 01 1 11 11
output:
5 2
result:
ok 2 number(s): "5 2"
Test #3:
score: 0
Accepted
time: 30ms
memory: 4316kb
input:
1 1000000 1000000 1000000 1000000 1 11 11
output:
2000000
result:
ok 1 number(s): "2000000"
Test #4:
score: -100
Wrong Answer
time: 49ms
memory: 4344kb
input:
10000 8 2 7 8 8 00 01 00 11 00 10 11 11 10 10 01 10 01 00 10 11 8 11 01 11 00 01 10 11 11 00 01 01 01 01 00 11 10 9 00 00 01 01 10 11 00 01 11 10 11 00 11 11 00 11 01 10 9 11 11 10 00 11 00 11 01 00 10 01 11 00 01 01 01 10 01 11 00 01 01 01 10 10 00 11 11 11 11 10 ...
output:
34 32 36 36 38 36 42 38 40 38 36 44 34 34 36 32 29 36 38 40 36 38 42 36 27 34 36 36 32 33 32 40 34 36 38 40 42 34 36 32 29 36 38 40 40 35 39 36 38 36 40 29 38 40 36 38 42 40 40 34 41 38 34 32 34 38 36 36 40 38 34 34 27 34 32 38 36 38 36 36 36 36 31 34 34 34 38 38 38 38 40 40 36 36 36 27 34 38 36 34 ...
result:
wrong answer 5th numbers differ - expected: '40', found: '38'