QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#783855#9802. Light Up the GridsolunarWA 1ms3940kbC++141.1kb2024-11-26 12:02:482024-11-26 12:03:17

Judging History

你现在查看的是测评时间为 2024-11-26 12:03:17 的历史记录

  • [2024-11-29 22:54:59]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:1ms
  • 内存:3788kb
  • [2024-11-26 12:03:17]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3940kb
  • [2024-11-26 12:02:48]
  • 提交

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: 3940kb

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'