QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#784604 | #9802. Light Up the Grid | solunar | WA | 0ms | 4060kb | C++14 | 1.4kb | 2024-11-26 15:29:04 | 2024-11-29 22:55:05 |
Judging History
answer
// 2024ICPCShenyangE
#include <iostream>
#include <algorithm>
using namespace std;
#include <math.h>
#include <memory.h>
int m;
int a1, a2, a3, a4;
char ope[9] = {1, 2, 4, 8, 3, 12, 5, 10, 15 };
long long a[9];
int grid;
long long dp[1<<16];
long long memoir(int s) {
if (dp[s] >= 0)
return dp[s];
dp[s] = 2e9;
for (int i = 0; i < 9; i++) {
int newset = 0;
for (int j = 0; j < 16; j++)
if ((s & (1 << j)) && ((j ^ ope[i]) != 15))
newset |= (1 << (j ^ ope[i]));
long long suba = (dp[newset] >= 0) ? dp[newset] : memoir(newset);
dp[s] = min(dp[s], a[i] + suba);
}
return dp[s];
}
int main() {
int t;
char ch;
ios::sync_with_stdio(false);
cin >> t >> a1 >> a2 >> a3 >> a4;
a[0] = a[1] = a[2] = a[3] = a1;
a[4] = a[5] = a2;
a[6] = a[7] = a3;
a[8] = a4;
for (int i = 0; i < (1 << 16); i++)
dp[i] = -1;
dp[0] = 0;
while (t--) {
cin >> m;
int status = 0;
for (int i = 0; i < m; i++) {
grid = 0;
for (int j = 0; j < 4; j++) {
cin >> ch;
if (ch == '1')
grid |= (1 << j);
}
status |= (1 << grid);
}
long long ans = 2e9;
for (int i = 0; i < 9; i++) {
int newset = 0;
for (int j = 0; j < 16; j++)
if ((status & (1 << j)) && ((j ^ ope[i]) != 15))
newset |= (1 << (j ^ ope[i]));
ans = min(ans, a[i] + dp[newset]);
}
cout << ans << endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4060kb
input:
2 1000 100 10 1 4 10 00 01 00 00 10 00 01 1 11 11
output:
0 0
result:
wrong answer 1st numbers differ - expected: '1121', found: '0'