2017 ICPC Naning Rake It In
题目链接
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相关推荐
- 2017 ICPC Naning I. Rake It In(alpha-beta剪枝)
原题地址:https://nanti.jisuanke.com/t/19975 题意:Alice和Bob在玩一种名为"Rake It In"的游戏,起初有一个44的棋盘,每一格为一 ...
- 2017 ICPC沈阳区域赛
2017 沈阳区域赛 题号 题目 难度 知识点 A BBP Formula B Bridge C Empty Convex Polygons D Defense of the Ancients E F ...
- 2017 ICPC西安区域赛 A - XOR (线段树并线性基)
链接:https://nanti.jisuanke.com/t/A1607 题面: Consider an array AA with n elements . Each of its element ...
- 计蒜客 17115 2017 ICPC 西安网络赛 B Coin
Problem nanti.jisuanke.com/t/17115 Reference 关于二项展开式系数和 [二项式定理][推导]计蒜客17115 2017 ACM-ICPC 亚洲区(西安赛区)网 ...
- 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 ...
- 2017 ICPC西安区域赛 A - XOR ,线段树合并线性基
题目链接:A - XOR 题意;给个数组,每次询问一个区间你可以挑任意个数的数字异或和 然后在或上k的最大值 题解:线性基不知道的先看这个,一个线性基可以log的求最大值把对应去区间的线性基求出来然后 ...
- 2017 icpc beijing J - Pangu and Stones
题意: 给你n堆石头,l,r,每次可以合并区间长度[l,r]的石子,合并代价为石子数目和 问你最后能否合并成一堆 0 : 合并代价 思路: 计算区间石子和的话先求个前缀和方便后面用 dp[i][j][ ...
- 2017 ICPC 乌鲁木齐
H:题目看错 背锅 #include <bits/stdc++.h> #include <vector> #define PI acos(-1.0) #define mem(a ...
- 2017 icpc 南宁
rerangement 构造 这种任意排列的题目应该往构造的方向去想,此题构造的思路有两个一个是想局部的形态,发现不太好弄,然后想整体,什么东西需要隔开,发现1 和 2 ,0 和 0 需要隔开.于是我 ...
最新文章
- linux sd卡 自动挂载 mdev,mdev实现U盘和SD卡的自动挂载
- opencv4.0.1配合contrib在linux下面安装编译全过程
- jmeter更改java内存,jmeter内存溢出解决方法
- javascript --- 再读作用域和闭包
- 架构师必须搞懂DNS,一篇文章就够了。
- 前端学习(2921):vue的事件
- 【软件领域知识整理】贵金属交易的名词解释(一)
- mongodb 存储过程 遍历表数据_一个mongodb存储过程
- 区分IE6,IE7,firefox三种浏览器的CSS HACK
- 基于mapreducer的图算法
- html动态创建table不成功的一个问题
- 绝对式编码器的ssi协议 stm32 hal
- 企业办理CMMI认证是怎么收费的?
- 计算机平面设计主要学什么 - 兔课网,兔课网:初学平面要怎么样构图?
- 通过 adb 设置音量
- OpenMP: sections分段并行
- ListView动态刷新某项Item
- js按下回车键调用方法
- 学数据挖掘就要懂数据
- CentOS7.2 上安装 Docker 教程