示例#1
0
int main(void) {
	dyn[(9 << 20) | (9 << 15) | (9 << 10) | (9 << 5) | 9] = -1;
	
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		Posit p;
		for (int j = 0; j < 6; j++) {
			scanf("%d", &p.cnt[j]);
		}
		if (CanWin(p)) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}
示例#2
0
bool CanWin(const Posit& p) {
	int x = p.encode();
	if (dyn[x]) return dyn[x] == 1;
	for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) {
		if (p.cnt[i] > p.cnt[j]) {
			Posit new_p = p;
			for (;;) {
				new_p.cnt[i]--; new_p.cnt[j]++;
				if (new_p.cnt[i] < new_p.cnt[j]) break;
				if (CanWin(new_p) == false) {
//					printf("%d %d %d %d %d %d. %d -> %d\n",
//						new_p.cnt[0], new_p.cnt[1], new_p.cnt[2],
//						new_p.cnt[3], new_p.cnt[4], new_p.cnt[5],
//						i, j);
					dyn[x] = 1;
					return true;
				}
			}
		}
	}
	dyn[x] = -1;
	return false;
}
示例#3
0
文件: hashGame.c 项目: rerthal/mc102
//verifica se a maquina pode vencer
int ComputerCanWin(int hash[HASH_DIMENSION][HASH_DIMENSION])
{
    return CanWin(hash,COMPUTER);
}
示例#4
0
文件: hashGame.c 项目: rerthal/mc102
//verifica se o usuario pode vencer
int PlayerCanWin(int hash[HASH_DIMENSION][HASH_DIMENSION])
{
    return CanWin(hash,PLAYER);
}