文档章节

Rikka with Game[技巧]----2019 杭电多校第九场:1005

o
 osc_g8254g7s
发布于 2019/08/19 18:04
字数 638
阅读 7
收藏 0

精选30+云产品,助力企业轻松上云!>>>

 

Rikka with Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


Problem Description
Though both Rikka and Yuta are busy with study, on their common leisure, they always spend time with each other and sometimes play some interesting games. 

Today, the rule of the game is quite simple. Given a string  s with only lowercase letters. Rikka and Yuta need to operate the string in turns while the first operation is taken by Rikka.

In each turn, the player has two choices: The first one is to terminate the game, and the second one is to select an index i of s and right shift the value of char si, i.e., ab,bc,,yz,za.

If the game is still alive after 2101 turns, i.e., after Yuta finishes his 2100 turns, the game will end automatically. The final result is the value of s when the game is over.

Now, Rikka wants to minimize the lexicographical order of the result while Yuta wants to maximize it. You are required to calculate the result of the game if both Rikka and Yuta play optimally.

For two string a and b with equal length ma is lexicographically smaller than b if and only if there exists an index i[1,n] which satisfies ai<bi and aj=bj holds for all j[1,i).
Input
The first line of the input contains an integer  T(1T100), the number of test cases.

For each test case, the input contains a single line with a single string with only lowercase letters, the initial value of s(1|s|100).

s(1|s|100).
Output
For each test case, output a single line with a single string, the answer.

 

Sample Input
2 a
zbc
Sample Output
  a
  bbc
 
 
思路:
  • 首先,当字符串中y或时,Rikka 应直接停止操作,因为原串就时他能取得的最小串;
  • 当字符串以z开头时,Rikka应将最左边的z拨动到a,此时的串变得更小,而Yuta应将Rikka拨动出的a拨动成b,因为此时b事Yuta能取得的最大串;
  • 当字符串以y开头后面接着z时,Rikka应跳过y去拨动第一个z,此时获得了更小串,注意,此时不能拨动y因为,当Rikka拨动y为z时,Yuta立即停止游戏,Rikka取得的不是最优解,故不符合题意,应跳过y去拨动z为a,Yuta此时应将Rikka拨动的a拨动成b,同第二中情况。
  • 在代码中应表现为,如果字符串没有z则直接返回原串,如果字符串中存在z且z前面没有东西或全是y则,应将第一个z变为b返回;

代码如下:

//1005
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char str[110];int len;
int main(){
    int t;
    scanf("%d",&t);
    int j;
    while(t--){
        scanf("%s",str);
        len =strlen(str);
        for(j = 0 ; j < len && str[j] == 'y' ;j++);
        if(str[j] == 'z') str[j] = 'b';
        printf("%s\n",str);
    }
    return 0;
}

 

 

 
o
粉丝 0
博文 500
码字总数 0
作品 0
私信 提问
加载中
请先登录后再评论。
2018暑假多校(杭电 + 牛客)

天坑。。。 杭电 dls代码:https://ideone.com/Wo55gi 官方题解:http://bestcoder.hdu.edu.cn/blog/ 2018 Multi-University Training Contest 1 1001 Maximum Multiple 打表找规律,发现只有......

osc_rzibnjco
2018/08/03
3
0
Rikka with Game[技巧]----2019 航电多校第九场:1005

Rikka with Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 0 Accepted Submission(s): 0 Problem Description Though bo......

我不是张小毛
2019/08/19
0
0
每日刷题记录

###9.30LuoguP3293 [SCOI2016]美味 主席树 ###9.23Luogu2711 小行星 网络流最小割Luogu3402 可持久化并查集 模板Atcoder ABC140E Second Sum 单调栈+分块Luogu4208 最小生成树计数 dfs暴力 ...

osc_575sntwo
2019/07/30
2
0
HDU 6685 Rikka with Coin (枚举 思维)

2019 杭电多校 9 1006 题目链接:HDU 6685 比赛链接:2019 Multi-University Training Contest 9 Problem Description Rikka hates coins, and she used to never carry any coins with her.......

osc_3rgq3dae
2019/08/20
3
0
2019杭电多校第二场

比赛总结 @辣鸡lfw,一开始算三角形那题没想到正解使用莫队乱搞,然后要选出50个最大的时候还用莫队。。。主席树区间第k大什么的完全忘记了 题解 1001 Another Chess Problem unsolved 1002...

osc_kel5e0sw
2019/07/26
6
0

没有更多内容

加载失败,请刷新页面

加载更多

Hacker News 简讯 2020-07-11

更新时间: 2020-07-11 00:00 Scientists make precise edits to mitochondrial DNA for first time - (nature.com) 科学家首次对线粒体DNA进行精确编辑 得分:66 | 评论:4 LibreOffice: The N......

FalconChen
49分钟前
95
0
是否有可能从另一个git存储库中挑选一个提交? - Is it possible to cherry-pick a commit from another git repository?

问题: I'm working with a git repository that needs a commit from another git repository that knows nothing of the first. 我正在使用一个git存储库,需要从另一个不知道第一个存储库......

技术盛宴
昨天
26
0
【LeetCode】53 盛最多水的容器

题目 解题思路 双指针法: https://leetcode-cn.com/problems/container-with-most-water/solution/sheng-zui-duo-shui-de-rong-qi-by-leetcode-solution/ 代码 public class Solution { ......

JaneRoad
昨天
20
0
阿里云OSS配置CDN加速

首先购买CDN流量包 然后添加域名 添加好后 然后将域名OSS.xxxx.com 解析到 生成的CDN域名上 这样就完成了

可达鸭眉头一皱
昨天
16
0
js 整数与小数正则替换片段

说明 /(\d+)/g 整数 /(\d+\.\d+)rem/g 小数 /(\d+\.\d+|\d+)rem/g 其中 | 或 条件 例子 全局查找带 rem 单位的,替换成 px 单位 let text = text.replace(/(\d+\.\d+|\d+)rem/g, function(s......

DrChenXX
昨天
17
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部