洛谷P2599||bzoj1413 [ZJOI2009]取石子游戏
2024-08-23 01:56:20
根本不会啊。。。
看题解吧
#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 ;
}
最新文章
- 嵌入式Linux驱动学习之路(二十五)虚拟网卡驱动程序
- [LeetCode] Sort Colors 颜色排序
- Linux上从Java程序中调用C函数
- zigbee学习之路(十三):基于协议栈的Usart 实验
- Webpack教程一
- yeoman的学习
- [改善Java代码]Lock与synchronized是不一样的
- linux,Centos,bash: service: command not found
- javascript、js操作json方法总结(json字符创转换json对象)
- 中国省市位置描述JSON数据
- Ioc在重构代码中的应用
- LogWriter: Operating system error 21(error not found) encountered
- WinForm的.Designer.cs代码内抛反射异常
- HSV color space
- 改变自己从学习linux开始
- springboot+jsp 遇到的坑
- bzoj 3779: 重组病毒
- Hadoop整理二(Hadoop分布式存储系统HDFS)
- CF1060C Maximum Subrectangle【乘法分配律】【最大子矩阵】
- python作业购物车(第二周)
热门文章
- codeforces A. Point on Spiral 解题报告
- apeche配置虚拟主机
- wiki中文语料+word2vec (python3.5 windows win7)
- 解决Exception:Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
- Windows_Program_Via_C_Translate_Win32编程的背景知识/基础知识_包括基本输入输出机制介绍
- bzoj 2655 calc —— 拉格朗日插值
- bzoj4247挂饰——DP
- Fire Game
- Outlook 开发2
- C/C++学习笔记1