QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#789158 | #9802. Light Up the Grid | wanghai673# | WA | 37ms | 12820kb | C++20 | 1.6kb | 2024-11-27 19:25:37 | 2024-11-27 19:25:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int T,a0,a1,a2,a3;
int f[20][1<<17];
void Min(int &x,int y)
{
if(y<x)x=y;
}
int main()
{
scanf("%d%d%d%d%d",&T,&a0,&a1,&a2,&a3);
int bt=(1<<16)-1;
for(int i=0;i<16;++i)
for(int j=0;j<=bt;++j)
f[i][j]=1e9;
f[15][0]=0;
for(int j=0;j<bt;++j)
for(int i=0;i<16;++i)
{
int nw3=i^15;
Min(f[nw3][j|1<<nw3],f[i][j]+a3);
int nw2=i^3;
Min(f[nw2][j|1<<nw2],f[i][j]+a2);
nw2=i^12;
Min(f[nw2][j|1<<nw2],f[i][j]+a2);
int nw1=i^5;
Min(f[nw1][j|1<<nw1],f[i][j]+a1);
nw1=i^10;
Min(f[nw1][j|1<<nw1],f[i][j]+a1);
int nw0=i^1;
Min(f[nw0][j|1<<nw0],f[i][j]+a0);
nw0=i^2;
Min(f[nw0][j|1<<nw0],f[i][j]+a0);
nw0=i^4;
Min(f[nw0][j|1<<nw0],f[i][j]+a0);
nw0=i^8;
Min(f[nw0][j|1<<nw0],f[i][j]+a0);
}
for(int i=0;i<16;++i)
{
for(int j=bt;j;--j)
{
int nw=j^(j&-j);
Min(f[i][nw],f[i][j]);
}
}
while(T--)
{
int m;
scanf("%d",&m);
int st=0,ans=1e9;
while(m--)
{
int sm=0;
for(int i=3;~i;--i)
{
int x;
scanf("%1d",&x);
sm|=x<<i;
}
st|=1<<sm;
}
for(int i=0;i<16;++i)
Min(ans,f[i][st]);
printf("%d\n",ans);
}
}
详细
Test #1:
score: 100
Accepted
time: 15ms
memory: 12820kb
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: 15ms
memory: 12328kb
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: 15ms
memory: 12644kb
input:
1 1000000 1000000 1000000 1000000 1 11 11
output:
2000000
result:
ok 1 number(s): "2000000"
Test #4:
score: -100
Wrong Answer
time: 37ms
memory: 12516kb
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 31 34 44 38 42 37 40 41 31 44 34 45 42 32 44 46 38 40 36 49 46 37 32 51 40 47 38 50 40 45 34 36 41 31 48 27 42 34 34 36 43 39 46 35 48 37 36 34 45 43 45 42 34 41 47 29 45 33 46 41 45 38 29 40 40 47 42 42 34 29 33 34 32 36 38 43 38 42 35 38 49 33 39 32 46 44 28 40 42 45 38 45 40 39 35 42 34 36 ...
result:
wrong answer 3rd numbers differ - expected: '36', found: '31'