Technocup 2019 C. Compress String】的更多相关文章

一个字符串 $s$,你要把它分成若干段,有两种合法的段 1.段长为 $1$,代价为 $a$ 2.这个段是前面所有段拼起来组成的字符串的字串,代价为 $b$ 问最小代价 $|s| \leq 5000$ sol: 赛后看到带 log 的过了十分不解... 考虑 dp $f_i = min(f_{i-1} + a,\space min\{f_j + b\})$ ($s[i+1,j]$ 要在 $s[1,i]$ 中作为子串出现) 子串的话写个 SAM 就可以线性求了,具体就是 extend 一个前缀,然后…
1.5 Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string would not become smaller than the original string, your met…
A. Technogoblet of Fire 题意:n个人分别属于m个不同的学校 每个学校的最强者能够选中 黑客要使 k个他选中的可以稳被选 所以就为这k个人伪造学校 问最小需要伪造多少个 思路:记录每个学校都有哪些人 每次看黑客选中的人是不是在学校是最强者(这里要处理能力一样的情况,如果有能力一样的为了保证稳进也要伪造一个学校) 然后就是模拟了 #include<bits/stdc++.h> #define FOR(i,f_start,f_end) for(int i=f_start;i&…
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++.h> using namespace std; int n,m,k; ; int main() { cin>>n>>m>>k; ;i<=k-;++i) { sum+=(n+(m-))*-(i)*; } cout<<sum<<endl;…
Compress String 时间限制:2000 ms  |  内存限制:65535 KB 难度:3 描写叙述 One day,a beautiful girl ask LYH to help her complete a complicated task-using a new compression method similar to Run Length Encoding(RLE) compress a string.Though the task is difficult, LYH i…
题面戳这里 A. Diana and Liana 首先如果s>ks>ks>k一定无解,特判一下.那么我们考虑找恰好满足满足题目中的要求的区间[l,r][l,r][l,r],那么需要要删去的数一定是(l−1)%k+max((r−l+1)−k,0)(l-1)\%k+max((r-l+1)-k,0)(l−1)%k+max((r−l+1)−k,0).前面的表示要把[1,l−1][1,l-1][1,l−1]区间删成kkk的倍数,后面的表示要把这个区间删到kkk长度以内.判断这个值是否不大于能够删的…
Given a string, replace adjacent, repeated characters with the character followed by the number of repeated occurrences. Assumptions The string is not null The characters used in the original string are guaranteed to be ‘a’ - ‘z’ Examples “abbcccdeee…
http://codeforces.com/contest/1030 B. Vasya and Cornfield 判断点是否在矩形内(包括边界) 把每条边转化为一个不等式 public static void main(String[] args) { IO io = new IO(); int n = io.nextInt(), d = io.nextInt(); int t = io.nextInt(); while (t-- > 0) { int x = io.nextInt(), y…
http://codeforces.com/contest/1031 (如果感觉一道题对于自己是有难度的,不要后退,懂0%的时候敲一遍,边敲边想,懂30%的时候敲一遍,边敲边想,懂60%的时候敲一遍,边敲边想,(真实情况是你其实根本不用敲那么多遍……),然后,这道题你就差不多可以拿下了ψ(`∇´)ψ) (IO模板在最后的蛋里) A. Golden Plate n*m矩形,最外圈为第一圈,间隔着选k个圈,问总共占多少给格子 每圈贡献=2n‘+2m'-4,圈圈长宽以-4递减下去 public sta…
A. Right-Left Cipher time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves ciphers. He has invented his own cipher called Right-Left. Right-Left cipher is used for strings. To encr…