J:A Game about Increasing Sequences

不是特别会博弈,只能说一下大概意思

Alice and Bob like playing games.

The game is played on a sequence of length n. Alice and Bob take turns performing the operation, with Alice going first.

In each operation, the player can remove an element from the beginning or the end of the sequence.

If this operation is not the first operation of the game, the removed element must be strictly greater than all the previously removed elements.

The player who cannot perform the operation loses.

Please determine who will win the game if both Alice and Bob play the game optimally.

输入格式:

The first line contains a single integers n(1≤n≤10^5),representing the length of the sequence.

The second line contains n integers a1​,a2​,...,an​(1≤ai​≤10^5),representing the sequence.

输出格式:

For each test case, print "Alice" if Alice will win the game, otherwise print "Bob".

输入样例:

3
1 3 2

输出样例:

Bob

代码长度限制

16 KB

时间限制

1000 ms

内存限制

128 MB

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef double db;
const int N=1e5+10;
int a[N],n;
signed main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin>>n;for(int i=1;i<=n;i++){cin>>a[i];}int l=1;for(int i=2;i<=n;i++){if(a[i]>a[i-1])l++;else break;}int r=1;for(int i=n-1;i>=1;i--){if(a[i]>a[i+1])r++;else break;}if(l%2==0&&r%2==0){puts("Bob");}else{puts("Alice");}return 0;
}

我们首先不考虑首位相同的清空,假设数值大的那一端叫大头,数值小的叫小头

如果大头那端是连续的奇数个,Alice赢

否则,Alice会选择小头那一端,但是两个人再也不会去大头那一端,因为一去,后面那个人就会变成老六,跟着你。所以如果是小头那端是连续的奇数个,Alice赢。否则Bob赢。

The 2022 ICPC Asia Regionals Online Contest (II) J相关推荐

  1. The 2022 ICPC Asia Regionals Online Contest (II) A、B、E、F、G、J、L

    文章目录 A-Yet Another Remainder 题目 题解 B-Non-decreasing Array 题目 题解 E-An Interesting Sequence 题目 题解 F-In ...

  2. The 2022 ICPC Asia Regionals Online Contest (II) 2022ICPC第二场网络赛 ABEFGJKL题解

    文章目录 A Yet Another Remainder[费马小定理] B Non-decreasing Array[线性DP] E An Interesting Sequence[签到] F Inf ...

  3. The 2022 ICPC Asia Regionals Online Contest (II) B

    B : Non-decreasing Array You are given a non-decreasing array of integers a1​,a2​,-,an​. In one oper ...

  4. The 2022 ICPC Asia Regionals Online Contest (I)

    D题 The 2022 ICPC Asia Regionals Online Contest (I) 03:14:13 H Step Debugging 作者 pku 单位 北京大学 Rikka is ...

  5. 2021 ICPC Asia Regionals Online Contest (II) Problem G. Limit

    The 2021 ICPC Asia Regionals Online Contest (II) Problem G. Limit 在欧教的指导下,复习了下高数知识,写下了这题的题解- 做这道题之前, ...

  6. 【ICPC 2021网络赛2】The 2021 ICPC Asia Regionals Online Contest (II)签到题5题

    M. Addition 题意: 给出n,接下来三行,每行n位二进制数,分别表示符号sgn{-1,1}和a{0,1}, b{0,1}. 令c=a+b(a和sgn每位相乘得到数a),最后将c拆成每一位输出 ...

  7. 2021ICPC网络赛第二场The 2021 ICPC Asia Regionals Online Contest (II) 【L Euler Function】

    分析: 根据欧拉函数的那个性质 if(p是质数){if(i % p == 0) f[i * p] = f[i] * p;else f[i * p] = f[i] * (p - 1);} 每次区间乘的那 ...

  8. The 2022 ICPC Asia Regionals Online Contest - A 01 Sequence

    01 Sequence 题目 Given a binary cyclic sequence S of length n, whose elements are either 0 or 1, you c ...

  9. The 2021 ICPC Asia Regionals Online Contest (II)

    比赛链接 A. Sort 暴力 k=1k=1k=1 检查数组是否有序: k=2k=2k=2 相当于再环上找个起点使得数组有序,直接判断: k≥3k\ge 3k≥3 考虑插入排序,每次暴力找到第 iii ...

最新文章

  1. 无缝衔接的人会遭报应吗_还为幼小衔接发愁吗?学会4招,孩子养成好习惯,与小学无缝对接...
  2. python os.system执行shell 命令
  3. groovy学习(一)
  4. Java集合和泛型练习及面试题——博客园:师妹开讲啦
  5. SpringCloud学习笔记009---杂七杂八003:spring的@Transactional注解详细用法
  6. Codevs 3269 混合背包(二进制优化)
  7. 47多项式02——整除
  8. 测量软件应用系统的聚合复杂度【翻译稿】
  9. kafka搭建、学习(一)
  10. node koa2 mysql_Node.js + Koa2 + MySQL + Vue.js 实战开发一套完整个人博客项目网站
  11. 联想用u盘重装系统步骤_如何使用U盘重装系统?使用U盘重装系统步骤详解
  12. 汇编----正确区分LJMP、AJMP、SJMP、JMP跳转指令
  13. pandas 排序 excel
  14. 使用STN的行人属性识别
  15. elasticsearch报错:bootstrap checks failed. You must address the points described in the following [1]
  16. Windbg调试工具介绍
  17. 计算机视觉在农业领域中的应用
  18. 使用yum下载文件报No module named urlgrabber.grabber错
  19. 分享几个有意思的游戏
  20. Pion流媒体服务测试

热门文章

  1. zend studio php 错误提示,如何解决Win7打开启动ZendStudio PHP时提示错误
  2. 易语言服务器调试输出为假,易语言判断、如果真、文本到整数比较时,调试时运行正常,编译后不正常...
  3. Java语言的三大特性
  4. Windows系统制作安装
  5. MySQL 数据库 模糊查询和聚合函数
  6. 推荐一个好用的tcp udp调试工具——TCP/UDP Debugger
  7. 【案例教程】地下水环评(一级)实践技术及Modflow地下水数值模拟
  8. docker的基本用法
  9. 接口之----手机号验证接口api
  10. win10 charles 抓 IOS https