QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#783855 | #9802. Light Up the Grid | solunar | WA | 1ms | 3788kb | C++14 | 1.1kb | 2024-11-26 12:02:48 | 2024-11-29 22:54:59 |
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 };
int a[9];
int grid;
int dp[1<<16];
int memoir(int s) {
if (dp[s] >= 0)
return dp[s];
dp[s] = 2e9;
for (int i = 0; i < 9; i++) {
int news = 0;
for (int j = 0; j < 16; j++)
if ((s & (1 << j)) && ((j ^ ope[i]) != 15))
news |= (1 << (j ^ ope[i]));
int suba = (dp[news] >= 0) ? dp[news] : memoir(news);
dp[s] = min(dp[s], a[i] + suba);
}
return dp[s];
}
int main() {
int t;
char ch;
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;
dp[0] = 0;
while (t--) {
cin >> m;
memset(dp, 0xff, sizeof(dp));
int s = 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);
}
s |= (1 << grid);
}
int ans = memoir(s);
cout << ans << endl;
}
return 0;
}
/*
5 1000 100 10 1
4
10
00
01
00
00
10
00
01
1
11
11
1
10
11
*/
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3788kb
input:
2 1000 100 10 1 4 10 00 01 00 00 10 00 01 1 11 11
output:
2000000000 2000000000
result:
wrong answer 1st numbers differ - expected: '1121', found: '2000000000'