[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 ...
随机推荐
- 解决jQuery中input 失去焦点之后,不能再获取到焦点
//编辑过敏史 if(iToolbar == 'editGMS'){ lstype="gms"; var gms=""; if(gmstype=="0 ...
- EPEL添加与删除
EPEL简介 EPEL的全称叫 Extra Packages for Enterprise Linux,由Fedora社区打造,如它的全称,这是一个为红帽系列及衍生发行版如CentOS.Fedora提 ...
- 2020qbxt游记
csp-s 突破 ----------------------------------------- 1-15 下午才走,这实在是太恶心了.然而因为感冒,当众大佬们都在上学的时候,我在家里睡觉. 2: ...
- [TJOI2008] 小偷
TJOI2008小偷 题目背景 一位著名的小偷进入了一个充满宝石的储藏室,这个储藏室是由一连串房间构成的,房间的标号从0开始,想进入第i个房间就必须从第i-1个房间进入,如图: 题目描述 上图为三个房 ...
- 产生随机数(rand()函数和srand()函数)
有时候,我们需要随机产生一个在某范围的数,C/C++提供了一个库函数rand()来产生随机数. 函数原型:int rand(void); 功能:返回一个[0,RAND_MAX]间的随机整数.其中RAN ...
- ubuntu set up 7 - power
https://askubuntu.com/questions/1078939/ubuntu-18-04-battery-life http://tipsonubuntu.com/2018/11/18 ...
- js面向对象怎么理解
js面向对象怎么理解 <一>. 认识对象.首先要认识对象:在编程中,对象(object)是具体的某一个实例,唯一的某一个个体.如:电脑就是一个统称,而你面前的这一台电脑就是对象.而电脑的统 ...
- Python Django文件上传
文件保存本地 view视图 def update(request): if request.method =='GET': return render(request,'update.html') e ...
- [CF1303A] Erasing Zeroes
Solution 找到边界然后循环扫一遍数个数即可 #include <bits/stdc++.h> using namespace std; int n; const int N = 1 ...
- 使用ssh localhost命令,发生异常ssh: connect to host localhost port 22: Connection refused
使用"ssh localhost"命令,失败: 问题分析如下: 出现这个问题是因为Ubuntu默认没有安装openssh-server.检查是否安装了openssh-server, ...