USACO Section 3.3: A Game
第一次碰到博弈论题目,是很棘手,博弈论题目要考虑全局最优的解法,我第一次用了局部最优的,而且vector也没pop_front()操作。后来看了网上的用dp的方法解的。
博弈论的题目基本都得用dp法子,因为你得从最简单的情况开始向上推算。
/* ID: yingzho1 LANG: C++ TASK: game1 */ #include <iostream> #include <fstream> #include <string> #include <map> #include <vector> #include <set> #include <algorithm> #include <stdio.h> #include <queue> #include <cstring> #include <cmath> #include <list> #include <cstdio> #include <cstdlib> #include <limits> #include <stack> using namespace std; ifstream fin("game1.in"); ofstream fout("game1.out"); int N; int main() { fin >> N; vector<int> board(N); ; vector<vector<int> > score(N, vector<int>(N)), sum(N, vector<int>(N)); ; i < N; i++) { fin >> board[i]; total += board[i]; sum[i][i] = score[i][i] = board[i]; } ; i < N; i++) { ; j < N; j++) { sum[i][j] = sum[i][j-] + board[j]; } } ; l < N; l++) { ; i < N-l; i++) { score[i][i+l] = sum[i][i+l] - min(score[i][i+l-], score[i+][i+l]); } } fout << score[][N-] << ][N-] << endl; ; }
USACO Section 3.3: A Game的更多相关文章
- USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)
usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...
- USACO Section 3.3: Riding the Fences
典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...
- USACO Section 3.3 Camlot(BFS)
BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...
- [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)
nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...
- USACO Section 5.3 Big Barn(dp)
USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1 (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .d ...
- USACO Section 1.3 Prime Cryptarithm 解题报告
题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...
- USACO Section 1.1 Your Ride Is Here 解题报告
题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...
- USACO Section 1.1-1 Your Ride Is Here
USACO 1.1-1 Your Ride Is Here 你的飞碟在这儿 众所周知,在每一个彗星后都有一只UFO.这些UFO时常来收集地球上的忠诚支持者.不幸的是,他们的飞碟每次出行都只能带上一组支 ...
- USACO section 1.1 C++题解
USACO section1.1:DONE 2017.03.03 TEXT Submitting Solutions DONE 2017.03.04 PROB Your Ride Is Here [A ...
- USACO Section 1.1PROB Your Ride Is Here
题目传送门 不能提交哦 http://www.nocow.cn/index.php/Translate:USACO/ride /* ID: jusonal1 PROG: ride LANG: C+ ...
随机推荐
- android开发,socket发送文件,read阻塞,得不到文件尾-1
这是我的接收文件代码:开始可以读取到-1,但是现在又读取不到了,所以才加上红色字解决的(注释的代码) File file = new File(mfilePath,"chetou." ...
- web开发--文档下载
GOOGLE在线文档下载地址分享(GOOGLE的文档地址暂不能用了,会放在其它位置..) GOOGLE的在线文档功能好象挂掉了...等找个其它存放的位置把这些文档再上传上去... 存在GOOGLE里面 ...
- git删除远程分支和本地分支
问题描述: 当我们集体进行项目时,将自定义分支push到主分支master之后,如何删除远程的自定义分支呢 问题解决: (1)使用命令git branch -a 查看所有分支 ...
- 搜索 基础 AC 2014-01-14 15:53 170人阅读 评论(0) 收藏
题目网址:http://haut.openjudge.cn/xiyoulianxi1/1/ 1:晶矿的个数 查看 提交 统计 提问 总时间限制: 1000ms 内存限制: 65536kB 描述 ...
- MongoDB 基础
1. 安装 mongodb-win32-x86_64-2008plus-2.6.12-signed.msi,下载地址 https://www.mongodb.com/download-center#c ...
- mysql Communications link failure,C3p0的参数详解
MySQL默认一个连接空闲8小时候就会自动断开,而这时程序以为连接还能使用,然后在使用的时候就会出现Communications link failure异常. 这时需要进行两步设置,有时候只设置My ...
- eclipse中本地项目怎么和svn中的项目关联?
网速不好,通过别的方式把项目下载到本地硬盘,然后导入eclipse,代码修改后怎么提交到svn呢? 这个纠结了好久的问题... 首先要确定eclipse中安装了svn插件. 然后在“svn资源库研究” ...
- Understanding Convolution in Deep Learning
Understanding Convolution in Deep Learning Convolution is probably the most important concept in dee ...
- Beginners Guide To Learn Dimension Reduction Techniques
Beginners Guide To Learn Dimension Reduction Techniques Introduction Brevity is the soul of wit This ...
- [百度空间] [转]DLL地狱及其解决方案
DLL地狱及其解决方案 原作者:Ivan S Zapreev 译者:陆其明概要 本文将要介绍DLL的向后兼容性问题,也就是著名的“DLL Hell”问题.首先我会列出自己的研究结果,其中包括其它一些研 ...