[CF1220C] Substring Game in the Lesson - 博弈论
[CF1220C]
Description
给定一个字符串 \(S\) , 同时维护一个区间 \([l,r]\) 。轮流操作,每次可以扩展到一个新区间使得原区间是新区间的真子区间,并且字典序更小,不能操作的人输。初态区间为 \([k,k]\) ,你需要对 \(k=1,2,...,|S|\) 判断胜负性。
Solution
很容易发现游戏最多玩一轮,所以只需要判断每个字母之前有没有更小的字母就可以了。
#include <bits/stdc++.h>
using namespace std;
string str;
int c[27];
int main()
{
ios::sync_with_stdio(false);
cin>>str;
int n=str.length();
for(int i=0;i<n;i++)
{
c[str[i]-'a'+1]++;
int flag=0;
for(int j=0;j<str[i]-'a'+1;j++) flag+=c[j];
if(flag) cout<<"Ann"<<endl;
else cout<<"Mike"<<endl;
}
}
[CF1220C] Substring Game in the Lesson - 博弈论的更多相关文章
- Codeforces Round #586 (Div. 1 + Div. 2) C. Substring Game in the Lesson
链接: https://codeforces.com/contest/1220/problem/C 题意: Mike and Ann are sitting in the classroom. The ...
- Codeforces 1220C. Substring Game in the Lesson
传送门 首先显然的,如果 $l$ 能移动,那么 $r$ 一定可以随便移动,如果 $l$ 不动,那么 $r$ 一定不能动 那么我们现在只要考虑 $l$ 的移动即可 考虑找到位置 $k$ 之前的最左边的最 ...
- Codeforces Round #586 (Div. 1 + Div. 2)
传送门 A. Cards 记录一下出现的个数就行. Code #include <bits/stdc++.h> #define MP make_pair #define fi first ...
- Codeforces Round #586
目录 Contest Info A. Cards B. Multiplication Table C. Substring Game in the Lesson D. Alex and Julian ...
- LeetCode[3] Longest Substring Without Repeating Characters
题目描述 Given a string, find the length of the longest substring without repeating characters. For exam ...
- 最长回文子串-LeetCode 5 Longest Palindromic Substring
题目描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximum ...
- POJ3693 Maximum repetition substring [后缀数组 ST表]
Maximum repetition substring Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9458 Acc ...
- [LeetCode] Longest Substring with At Least K Repeating Characters 至少有K个重复字符的最长子字符串
Find the length of the longest substring T of a given string (consists of lowercase letters only) su ...
- Lesson 18 He often does this!
Text After I had had lunch at a village pub, I looked for my bag. I had left it on a chair beside th ...
随机推荐
- c#XML的基本使用
创建XML文档 static void Main(string[] args) { //1.引入命名空间 //2.创建XML文档对象 XmlDocument xmldoc = new XmlDocum ...
- 由于找不到opencv_world320d.dll,无法继续执行代码。解决方案
将 opencv 安装路径 目录\opencv\build\x64\vc14\bin 中 3 个后缀是.dll 的应用程序扩展复制到 C:\Windows\System32 中 完美解决!
- Scout YYF I POJ - 3744【矩阵乘法优化求概率】
题意: 一条路上有 $n$ 个地雷,YYF 从位置 $1$ 出发,走一步的概率为 $p$,走两步的概率是 $(1-p)$.求 YYF 能顺利通过这条路的概率. 数据范围: $1\leq n \leq ...
- 解决const char* to char* 的错误
一般情况下 char* string = "abc"; 编译后会出现标题中的错误. 我们只需要在字符串前加上const_cast<char*>即可,这个作用是丢弃变量的 ...
- 基于光盘配置yum源
#开启自动挂载服务 systemctl start autofs #设置开机自动挂载 systemctl enable autofs #光盘自动挂载路径/misc/cd “包含repoda ...
- js 时间格式转换
js时间格式转换 格式化时间转成时间戳 //格式化转时间戳(单位秒) function strtotime(strtime) { strtime = strtime.substring(0, 19); ...
- PAT (Basic Level) Practice (中文)1046 划拳 (15 分)
划拳是古老中国酒文化的一个有趣的组成部分.酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字.如果谁比划出的数字正好等于两人喊出的数字之和,谁就赢了,输家罚一杯酒.两人同赢或两人同输 ...
- 启动zabbix-server/agent报错:cannot open "/etc/zabbix/logs/zabbix_server.log": [13] Permission denied
注:该报错解决方式同样适用于zabbix-agent 启动zabbix-server报错信息如下: 2月 27 16:52:44 localhost.localdomain zabbix_server ...
- Ex-KMP(模板)
首先,明白Ex-KMP是干什么的: 给定两个字符串母串S和子串T(长度分别为n和m),下标从0开始,定义extend[i]等于S[i]-S[n-1]与T的最长公共前缀的长度,求出所有的extend[i ...
- 用友UAP NC 单据新增数据时抛出"流程平台缓存中不存在该单据或交易类型=HB06"
正常单据新增时,抛出异常"流程平台缓存中不存在该单据或交易类型=HB06"