bzoj1413

洛谷P2599

根本不会啊。。。

看题解吧

 #include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
int T;
int n;
int a[];
int lft[][],rht[][];
//[l,r]区间左侧加/右某个元素使得成为必败态
int main()
{
int i,l,r,t1,t2,x;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(i=;i<=n;++i)
scanf("%d",a+i);
if(n==)
{
printf("%d\n",);
continue;
}
if(n==)
{
printf("%d\n",int(a[]!=a[]));
continue;
}
for(i=;i<=n;++i)
lft[i][i]=rht[i][i]=a[i];
for(i=;i<=n;++i)
{
for(l=;l<=n-i+;++l)
{
r=l+i-;
t1=lft[l][r-];t2=rht[l][r-];x=a[r];
if(t2==x) lft[l][r]=;
else if(x<t1&&x<t2) lft[l][r]=x;
else if(x>t1&&x>t2) lft[l][r]=x;
else if(t1<=x&&x<t2) lft[l][r]=x+;
else if(t2<x&&x<=t1) lft[l][r]=x-;
}
for(l=;l<=n-i+;++l)
{
r=l+i-;
t1=lft[l+][r];t2=rht[l+][r];x=a[l];
if(t1==x) rht[l][r]=;
else if(x<t1&&x<t2) rht[l][r]=x;
else if(x>t1&&x>t2) rht[l][r]=x;
else if(t2<=x&&x<t1) rht[l][r]=x+;
else if(t1<x&&x<=t2) rht[l][r]=x-;
}
}
printf("%d\n",int(lft[][n]!=a[]));
}
return ;
}

最新文章

  1. 嵌入式Linux驱动学习之路(二十五)虚拟网卡驱动程序
  2. [LeetCode] Sort Colors 颜色排序
  3. Linux上从Java程序中调用C函数
  4. zigbee学习之路(十三):基于协议栈的Usart 实验
  5. Webpack教程一
  6. yeoman的学习
  7. [改善Java代码]Lock与synchronized是不一样的
  8. linux,Centos,bash: service: command not found
  9. javascript、js操作json方法总结(json字符创转换json对象)
  10. 中国省市位置描述JSON数据
  11. Ioc在重构代码中的应用
  12. LogWriter: Operating system error 21(error not found) encountered
  13. WinForm的.Designer.cs代码内抛反射异常
  14. HSV color space
  15. 改变自己从学习linux开始
  16. springboot+jsp 遇到的坑
  17. bzoj 3779: 重组病毒
  18. Hadoop整理二(Hadoop分布式存储系统HDFS)
  19. CF1060C Maximum Subrectangle【乘法分配律】【最大子矩阵】
  20. python作业购物车(第二周)

热门文章

  1. codeforces A. Point on Spiral 解题报告
  2. apeche配置虚拟主机
  3. wiki中文语料+word2vec (python3.5 windows win7)
  4. 解决Exception:Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
  5. Windows_Program_Via_C_Translate_Win32编程的背景知识/基础知识_包括基本输入输出机制介绍
  6. bzoj 2655 calc —— 拉格朗日插值
  7. bzoj4247挂饰——DP
  8. Fire Game
  9. Outlook 开发2
  10. C/C++学习笔记1