题目链接

alpha-beta剪枝

#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<stack>typedef long long ll;
const ll mod = 1000000007;
const int inf = unsigned(-1) >> 2;
const int maxn = 1e5 + 5;using namespace std;int sum, winx, winy;
int k;
int Map[5][5];int rote(int x, int y)
{swap(Map[x][y], Map[x + 1][y]);swap(Map[x][y + 1], Map[x + 1][y + 1]);swap(Map[x][y], Map[x + 1][y + 1]);return Map[x][y] + Map[x + 1][y] + Map[x][y + 1] + Map[x + 1][y + 1];
}void rerote(int x, int y)
{swap(Map[x][y], Map[x + 1][y + 1]);swap(Map[x][y + 1], Map[x + 1][y + 1]);swap(Map[x][y], Map[x + 1][y]);
}int DFS(int sum, int dep, int alpha, int beta)
{if(dep == 2 * k){return sum;}for(int i = 0; i < 3; i++){for(int j = 0; j < 3; j++){int tmp = DFS(sum + rote(i, j), dep + 1, alpha, beta);rerote(i, j);if(dep & 1)beta = min(beta, tmp);elsealpha = max(alpha, tmp);if(beta <= alpha)return dep & 1 ? beta : alpha;}}return dep & 1 ? beta : alpha;
}int main()
{ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);int t;cin >> t;while(t--){cin >> k;for(int i = 0; i < 4; i++){for(int j = 0; j < 4; j++){cin >> Map[i][j];}}cout << DFS(sum, 0, -inf, inf) << endl;}return 0;
}

2017 ICPC Naning Rake It In相关推荐

  1. 2017 ICPC Naning I. Rake It In(alpha-beta剪枝)

    原题地址:https://nanti.jisuanke.com/t/19975 题意:Alice和Bob在玩一种名为"Rake It In"的游戏,起初有一个44的棋盘,每一格为一 ...

  2. 2017 ICPC沈阳区域赛

    2017 沈阳区域赛 题号 题目 难度 知识点 A BBP Formula B Bridge C Empty Convex Polygons D Defense of the Ancients E F ...

  3. 2017 ICPC西安区域赛 A - XOR (线段树并线性基)

    链接:https://nanti.jisuanke.com/t/A1607 题面: Consider an array AA with n elements . Each of its element ...

  4. 计蒜客 17115 2017 ICPC 西安网络赛 B Coin

    Problem nanti.jisuanke.com/t/17115 Reference 关于二项展开式系数和 [二项式定理][推导]计蒜客17115 2017 ACM-ICPC 亚洲区(西安赛区)网 ...

  5. 2017 icpc 西安赛区 B.Coin(推公式+二项式定理)

    Bob has a not even coin, every time he tosses the coin, the probability that the coin's front face u ...

  6. 2017 ICPC西安区域赛 A - XOR ,线段树合并线性基

    题目链接:A - XOR 题意;给个数组,每次询问一个区间你可以挑任意个数的数字异或和 然后在或上k的最大值 题解:线性基不知道的先看这个,一个线性基可以log的求最大值把对应去区间的线性基求出来然后 ...

  7. 2017 icpc beijing J - Pangu and Stones

    题意: 给你n堆石头,l,r,每次可以合并区间长度[l,r]的石子,合并代价为石子数目和 问你最后能否合并成一堆 0 : 合并代价 思路: 计算区间石子和的话先求个前缀和方便后面用 dp[i][j][ ...

  8. 2017 ICPC 乌鲁木齐

    H:题目看错 背锅 #include <bits/stdc++.h> #include <vector> #define PI acos(-1.0) #define mem(a ...

  9. 2017 icpc 南宁

    rerangement 构造 这种任意排列的题目应该往构造的方向去想,此题构造的思路有两个一个是想局部的形态,发现不太好弄,然后想整体,什么东西需要隔开,发现1 和 2 ,0 和 0 需要隔开.于是我 ...

最新文章

  1. linux sd卡 自动挂载 mdev,mdev实现U盘和SD卡的自动挂载
  2. opencv4.0.1配合contrib在linux下面安装编译全过程
  3. jmeter更改java内存,jmeter内存溢出解决方法
  4. javascript --- 再读作用域和闭包
  5. 架构师必须搞懂DNS,一篇文章就够了。
  6. 前端学习(2921):vue的事件
  7. 【软件领域知识整理】贵金属交易的名词解释(一)
  8. mongodb 存储过程 遍历表数据_一个mongodb存储过程
  9. 区分IE6,IE7,firefox三种浏览器的CSS HACK
  10. 基于mapreducer的图算法
  11. html动态创建table不成功的一个问题
  12. 绝对式编码器的ssi协议 stm32 hal
  13. 企业办理CMMI认证是怎么收费的?
  14. 计算机平面设计主要学什么 - 兔课网,兔课网:初学平面要怎么样构图?
  15. 通过 adb 设置音量
  16. OpenMP: sections分段并行
  17. ListView动态刷新某项Item
  18. js按下回车键调用方法
  19. 学数据挖掘就要懂数据
  20. CentOS7.2 上安装 Docker 教程

热门文章

  1. 百度AI攻略:增值税发票识别
  2. 全渠道客户体验:战略和优势
  3. ESXi 6.7 克隆虚拟机
  4. Netty教程06:netty实现群聊私聊
  5. 运维人员打字耍不要快_Linux运维人员应该知道的系统故障排查及修复方法
  6. Beam Search的学习笔记(附代码实现)
  7. 优化WinXP启动 加速开机时间(转)
  8. 刷1000遍奥数题,不如学会这几道逻辑题,让孩子秒懂数学,学习早开窍!
  9. HR给程序员挖坑:离职证明写被裁,才能拿补偿!
  10. win10的ie打不开,用注册表解决