codeforces上某题】的更多相关文章

一道codeforces上的题目. 题目大意: 定义有k个不同的字符的字符串为好字符串.现在给出一个字符串,求解对该字符串的每个前缀Si至少是多少个好字符串的连接,若不能由好字符串连接而成则输出-1. 例:k = 2 abac至少是ab和ac这两个好字符串的连接. 字符串长度<=2e5 看了一下网上的题解都是这样子的DP+数据结构尺取+dp+线段树比较麻烦. 列出基本DP式:f[i]={f[j]+1} S(j+1)-i为好串显然对于i,满足条件的j的区间是单调不降的,因此,可以放一个指针j在i后…
Codeforces VP/补题小记 1149 C. Tree Generator 给你一棵树的括号序列,每次交换两个括号,维护每次交换之后的直径. ​ 考虑括号序列维护树的路径信息和,是将左括号看做 \(-1\) ,右括号看做 \(1\) ,那么一段竖直向上的路径可以表示为括号序列的一个区间和,一段竖直向下的路径可以看做括号序列的一个区间和的相反数.我们要维护的是树的直径,也就是一段连续的和减去紧随其后的一段连续的差.具体来说就是 \[ \max_{\forall [l,r]}\{\sum_{…
使用实例: 使用onhashchange事件做一个简单的上一页下一页功能,并且当刷新页面时停留在当前页 html: <!DOCTYPE html><html><body><div id="demo"></div><button class="previous-page">上一题</button><button class="next-page">下一题…
As you might remember from our previous rounds, Vova really likes computer games. Now he is playing a strategy game known as Rage of Empires. In the game Vova can hire n different warriors; ith warrior has the type ai. Vova wants to create a balanced…
https://leetcode-cn.com/problemset/database/ --------------------------------------------------------------------------------- 转载, 原文:https://www.cnblogs.com/By-ruoyu/p/11311830.html 最近开始重拾算法,在 LeetCode上刷题.顺便也记录下解题报告以及优化思路. 题目链接:1.两数之和 题意 给定一个整数数组 nu…
鉴于Codeforces和atcoder上有很多神题,即使发呆了一整节数学课也是肝不出来,所以就记录一下. AGC033B LRUD Game 只要横坐标或者纵坐标超出范围就可以,所以我们只用看其中一维就可以了. 我们又知道,如果先手想要让它从左边出去,那么先手就会一直Left,后手就会一直Right. 所以枚举四种情况(L,R,U,D)就可以了. AGC033C Removing Coins 首先我们考虑链的情况,如果选的是端点,那么有一个点没有硬币,如果选的不是端点,那么有两个点没有硬币.所…
Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of t…
Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose…
在写上一随笔之前,在Codility网站上还做了一个道题(非Demo题):CountBoundedSlices,得了60分(害臊呀).今天又重新做了一下这个算法,性能提高了不少,但由于此题不是Demo题,不能重新在Codility网站测试了. 可以从http://codility.com/cert/view/certAWY5VP-D46CA7989XU4XEZT/details看到题目的详细信息. 这里把题目copy出来: An integer K and a non-empty zero-in…
题目地址:http://codeforces.com/contest/459/problem/C C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently Pashmak has been employed in a transportation company. The com…