D. Binary String Minimizing You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you c…
You are given a binary string of length nn (i. e. a string consisting of nn characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the given o…
B. Minimize the Permutation You are given a permutation of length n. Recall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation…
Codeforces Round #598 (Div. 3)- E. Yet Another Division Into Teams - 动态规划 [Problem Description] 给你\(n\)个数,将其划分为多组,对于每个组定义其\(d\)值为 组内的最大值减最小值,问如何划分使得最终所有组的\(d\)值之和最小.每个组至少要保证有\(3\)个数. [Solution] 将所有值从小到大排序,然后我们知道最多有\(5\)个人划分到同一组中,如果有\(6\)个人,那么划分为两组一定比…
A. Payment Without Change #include<bits/stdc++.h> using namespace std; #define int long long #define N 100500 int arr[N]; signed main(){ int _; cin>>_; while(_--){ int a,b,n,s; cin>>a>>b>>n>>s; int y=s/n; int x=min(a,…
Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/C Description In the evening, after the contest Ilya was bored, and he really felt like ma…
B. Equidistant String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem/B Description Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings conta…
E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个二进制不断地往右边移一位,每次答案加上这两个的交集,求最后的答案. 题解: 考虑第二个二进制每一位对答案的贡献就行了,然后对第一个二进制算前缀和就ok了. 代码如下: #include <bits/stdc++.h> using namespace std; typedef long long l…
链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa&…
Median String time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given two strings ss and tt, both consisting of exactly kk lowercase Latin letters, ss is lexicographically less than …
B. Obsessive String Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following proble…
F. Equalizing Two Strings You are given two strings s and t both of length n and both consisting of lowercase Latin letters. In one move, you can choose any length len from 1 to n and perform the following operation: Choose any contiguous substring o…
You are given two strings ss and tt both of length nn and both consisting of lowercase Latin letters. In one move, you can choose any length lenlen from 11 to nn and perform the following operation: Choose any contiguous substring of the string ss of…
题意:给你两个字符串\(s\)和\(t\),保证\(t\)的字典序大于\(s\),求他们字典序中间的字符串. 题解:我们假设题目给的不是字符串,而是两个10禁止的正整数,那么输出他们之间的数只要把他两加起来除\(2\)就行了,那么对于字符串又为何不可呢?我们可以将每个字母看成\(26\)进制的数,像高精度那样模拟加法运算的过程,然后再模拟除\(2\)的过程即可. 代码: int k; string s,t; int c[N]; int d[N]; int main() { ios::sync_w…
E. Yet Another Division Into Teams There are n students at your university. The programming skill of the i-th student is ai. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this unive…
C. Platforms Jumping There is a river of width n. The left bank of the river is cell 0 and the right bank is cell n+1 (more formally, the river can be represented as a sequence of n+2 cells numbered from 0 to n+1). There are also m wooden platforms o…