QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#783647#9802. Light Up the GridsolunarWA 1ms3884kbC++141.2kb2024-11-26 11:10:272024-11-29 22:54:45

Judging History

你现在查看的是最新测评结果

  • [2024-11-29 22:54:45]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:1ms
  • 内存:3884kb
  • [2024-11-26 11:10:28]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3884kb
  • [2024-11-26 11:10:27]
  • 提交

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 (s == 0)
		return dp[s] = 0;
	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, init15;
	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;
	while (t--) {
		cin >> m;
		init15 = false;
		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);
			}
			if (grid == 15)
				init15 = true;	
			s |= (1 << grid);
		}
		memset(dp, 0xff, sizeof(dp));
		int ans = memoir(s);
		cout << ans + 1 << endl;
	}
	return 0;
}
/*
1 1000 100 10 1
1
10
11
*/

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3884kb

input:

2 1000 100 10 1
4
10
00

01
00

00
10

00
01
1
11
11

output:

1122
3

result:

wrong answer 1st numbers differ - expected: '1121', found: '1122'