A - Minimizing the String solved 题意:给出一个字符串,可以移掉最多一个字符,在所有可能性中选取一个字典序最小的. 思路:显然,一定可以移掉一个字符,如果移掉的字符的后一个字符大于当前字符,那么字典序会变大. 那只需要从左往右,遇到第一个后面的字符大于当前字符的就可以移掉该字符. #include <bits/stdc++.h> using namespace std; #define N 200010 int n; char s[N]; int main()…
A. Minimizing the String time limit per test 1 second memory limit per test 256 megabytes Description: You are given a string ss consisting of nn lowercase Latin letters. You have to remove at most one (i.e. zero or one) character of this string in s…
题意:有一个\(01\)串,每次操作要先删除一个位置上的元素,然后删除相同前缀和,直到字符串被删完,问最多能操作多少次. 题解: 对于一个长度大于\(1\)的相同前缀,我们最多只能对它操作一次,然后就整个直接被删除了,所以它能提供的贡献就很少,我们记录所有连续的串的长度,然后我们最理想的删除条件是,最前面是单个的数(连续串长度为\(1\)),在它后面有长度大于\(1\)的连续相同串,我们每次删除一个连续相同串的一个字符,然后最前面的再删除一个,具体过程看代码吧. 代码: int t; int n…
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec Problem Description Input Output The only line should contain the minimal number of days required for the ship to reach the point (x2,y2)(x2,y2). If it…
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec Problem Description Input The input contains a single line consisting of 2 integers N and M (1≤N≤10^18, 2≤M≤100). Output Print one integer, the total n…