[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 ...
随机推荐
- MySQL学习 2019-12-30
启动mysql服务: net start mysql 关闭mysql服务: net stop mysql cmd清屏: cls mysql -V 输出版本信息并且退出 mysql -u 用户名 mys ...
- cf1242B
题意简述:给出一个n个点的完全图,边权要么是1要么是0,输入只给出权值的是1的那些边,求解最小生成树的权值 解答:边很多,我们考虑使用prim算法,prim算法的过程中维护了一个dis数组,这里我们可 ...
- [USACO19FEB]Painting the Barn G
题意 \(n\)个矩阵\((0\le x_1,y_1,x_2,y_2\le 200)\),可交,可以再放最多两个矩阵(这两个矩阵彼此不交),使得恰好被覆盖\(k\)次的位置最大.\(n,k\le 10 ...
- HQL查询 HQL Named parameter [xxx] not set 的解决办法
org.springframework.dao.InvalidDataAccessResourceUsageException: Named parameter [xxx] not set; nest ...
- JS 自动关闭页面
<script language=javascript> this.window.opener = null; window.close(); </script>
- Keras高层API之Metrics
在tf.keras中,metrics其实就是起到了一个测量表的作用,即测量损失或者模型精度的变化.metrics的使用分为以下四步: step1:Build a meter acc_meter = m ...
- Linux环境搭建及基础操作
一.Linux环境搭建 1.安装虚拟机软件(VMWare,Parallel) 虚拟机的作用:将本来不是适合当前操作系统的分区虚拟化成适合当前操作系统的分区格式 2.新建虚拟机: 类似买了一台新的电脑, ...
- gulp常用插件之gulp-rev-delete-origina使用
更多gulp常用插件使用请访问:gulp常用插件汇总 gulp-rev-delete-origina这是一款删除由gulp-rev或 gulp-rev-all重写的原始文件 . 更多使用文档请点击访问 ...
- C语言实现 循环队列
#include <stdio.h>#include <stdlib.h>#include <stdbool.h> typedef struct queue{ in ...
- Winform中怎样设置ContextMenuStrip右键菜单的选项ToolStripMenuItem添加照片
场景 怎样在Winform程序中添加鼠标右键时使子选项显示图片. 注: 博客主页: https://blog.csdn.net/badao_liumang_qizhi关注公众号 霸道的程序猿 获取编程 ...