3106: [cqoi2013]棋盘游戏
3106: [cqoi2013]棋盘游戏
分析:
极大极小搜索 + 记忆化。
代码
#include<bits/stdc++.h>
using namespace std;
typedef long long LL; const int INF = 1e9;
int f[][][][][][];
int dx[] = {,,,-,,,,-};
int dy[] = {,-,,,,-,,};
int n; int Minimax(int player,int step,int a,int b,int c,int d) {
if (step > n*) return INF;
if (a==c && b==d) {
if (player) return INF;
return ;
}
if (f[player][step][a][b][c][d]) return f[player][step][a][b][c][d];
int res = ,x = ,y = ;
if (player) { // 黑棋走
res = INF;
for (int i=; i<; ++i) {
x = c + dx[i], y = d + dy[i];
if (x>= && x<=n && y>= && y<=n) res = min(res,Minimax(player^,step+,a,b,x,y));
}
}
else { // 白棋走
for (int i=; i<; ++i) {
x = a + dx[i], y = b + dy[i];
if (x>= && x<=n && y>= && y<=n) res = max(res,Minimax(player^,step+,x,y,c,d));
}
}
res ++;
f[player][step][a][b][c][d] = res;
return res;
} int main() {
int a,b,c,d;
cin >> n >> a >> b >> c >> d;
if (abs(a-c)+abs(b-d) == ) puts("WHITE 1"); // 白子一步吃掉黑子
else printf("BLACK %d",Minimax(,,a,b,c,d));
return ;
}
3106: [cqoi2013]棋盘游戏的更多相关文章
- 【BZOJ 3106】 3106: [cqoi2013]棋盘游戏 (对抗搜索)
3106: [cqoi2013]棋盘游戏 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 544 Solved: 233 Description 一个 ...
- BZOJ 3106: [cqoi2013]棋盘游戏(对抗搜索)
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=3106 对抗搜索,f[x][y][a][b][c][d]表示当前谁走,走了几步,及位置. (因为 ...
- BZOJ 3106: [cqoi2013]棋盘游戏
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 859 Solved: 356[Submit][Status][Discuss] Descriptio ...
- bzoj千题计划200:bzoj3106: [cqoi2013]棋盘游戏
http://www.lydsy.com/JudgeOnline/problem.php?id=3106 白棋如果第一步不能赢,那么一定输 因为可以黑棋走的距离比白棋大,黑棋可以下一步吃掉白棋,也可以 ...
- [CQOI2013]棋盘游戏
Description 一个n*n(n>=2)棋盘上有黑白棋子各一枚.游戏者A和B轮流移动棋子,A先走. A的移动规则:只能移动白棋子.可以往上下左右四个方向之一移动一格. B的移动规则:只能移 ...
- bzoj3106 [cqoi2013]棋盘游戏
Description 一个n*n(n>=2)棋盘上有黑白棋子各一枚.游戏者A和B轮流移动棋子,A先走. l A的移动规则:只能移动白棋子.可以往上下左右四个方向之一移动一格. ...
- 【BZOJ3106】[CQOI2013] 棋盘游戏(对抗搜索)
点此看题面 大致题意: 在一张\(n*n\)的棋盘上有一枚黑棋子和一枚白棋子.白棋子先移动,然后是黑棋子.白棋子每次可以向上下左右四个方向中任一方向移动一步,黑棋子每次则可以向上下左右四个方向中任一方 ...
- P4576 [CQOI2013]棋盘游戏
传送门 很显然,除非白子和黑子相邻,否则必然是黑子获胜虽然我并没有看出来 那么现在对黑子来说它要尽可能快的赢,对白子它要多苟一会儿 然后就是这个叫做对抗搜索的东西了 //minamoto #inclu ...
- [bzoj3106][cqoi2013][棋盘游戏] (对抗搜索+博弈论)
Description 一个n*n(n>=2)棋盘上有黑白棋子各一枚.游戏者A和B轮流移动棋子,A先走. l A的移动规则:只能移动白棋子.可以往上下左右四个方向之一移动一格. ...
随机推荐
- c++基础知识_c++11 类默认函数的控制:"=default" 和 "=delete"函数
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <vecto ...
- Android进阶笔记10:ListView篇之ListView显示多种类型的条目(item)
ListView可以显示多种类型的条目布局,这里写显示两种布局的情况,其他类似. 1. 这是MainActivity,MainActivity的布局就是一个ListView,太简单了这里就不写了,直接 ...
- POJ 2531 深搜剪枝
题意:全局最大割. 分析:有相应的算法,数据量很小,可以枚举源点,汇点,最大流. 这里用DFS,状态定义:分成两个集合,刚开始S集合全部点,然后一个一个放,这是一个回溯的过程. 没剪枝也过了. 剪枝技 ...
- HDU 5723 Abandoned country 【最小生成树&&树上两点期望】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5723 Abandoned country Time Limit: 8000/4000 MS (Java/ ...
- Jmeter 登陆性能测试
1.打开Jmeter,新建一个线程组:测试计划--添加--Threads(users)---线程组 如图: 2.首先要添加一个HTTP默认请求,为什么要添加这个呢? 如果要测试的系统域名或者IP地址是 ...
- PAT 1063. Set Similarity
1063. Set Similarity 题目大意 给定 n 个集合, k 个询问, 求任意两个集合的并集和合集. 思路 一道裸的考察 STL 中 set 的题, 我居然还用 hash 错过一遍, 用 ...
- 11java基础继承
一. 继承相关 18.实现如下类之间的继承关系,并编写Music类来测试这些类. package com.hry.test; public class Instrument { ...
- 用c#语言编写银行利率
sing System;using System.Collections.Generic;using System.Linq;using System.Text; namespace ConsoleA ...
- Promise面试题
题目一 const promise = new Promise((resolve, reject) => { console.log(1); resolve(); console.log(2); ...
- ABAP术语-Document Number
Document Number 原文:http://www.cnblogs.com/qiangsheng/archive/2008/01/28/1055636.html Key which ident ...