Educational Codeforces Round 67 D. Subarray Sorting 传送门 题意: 给出两个数组\(a,b\),现在可以对\(a\)数组进行任意次排序,问最后能否得到\(b\)数组. \(n\leq 3*10^5,a\leq n.\) 思路: 首先注意到任意次排序可以等价于任意次交换两个相邻的数,当且仅当前一个数不小于后面一个数. 我一开始想的是按权值从小到大来构造,但最终发现这条路走不通. 正解就是比较直接的思路,按位置一个一个来匹配. 对于一个\(b_i\…
Educational Codeforces Round 67 CF1187B Letters Shop 二分 https://codeforces.com/contest/1187/submission/56313177 CF1187C Vasya And Array 直接构造 https://codeforces.com/contest/1187/submission/56316127 CF1187D Subarray Sorting 这题等System Test后更吧... CF1187E…
目录 Contest Info Solutions A. Stickers and Toys B. Letters Shop C. Vasya And Array D. Subarray Sorting E. Tree Painting Contest Info Data:2019.6.30 Solved:4/7 Solutions A. Stickers and Toys 题意: 有\(A\)物品\(s\)个,\(B\)物品\(t\)个,现在将这些物品装到\(n\)个箱子里,每个箱子只有一下三…
A 考虑之前选中没有一个的,那么结果就是\(min(n-s,n-t)\) 那么能选中的第一次就是这个结果\(+1\),但需要拥有两个 \((s>t)\)考虑一开始选不中\(t\),则但选中\(t\)时\(s\)也一定被选中了\((\)最坏的情况为\(s\)与\(t\)并集最小\()\) \(ans=n-min(s,t)+1\) B 简单想的复杂度高的算法:先\(sum_{i,j}\)表示文本串前\(i\)个字符\(j\)字符的个数 匹配串也用\(a\)统计每个字符的个数,二分一下判是否满足\(O…
题意:给出一个字符串s, 可以从左往右拿走s的字符, 至少要到s的第几个位置才能拼成t 思路:用二维数组记录前缀,然后二分即可. #include<bits/stdc++.h> using namespace std; #define inf 5000000 #define N 210050 ]; ]; string s; string str; int n; bool slove(int id) { ; i<; i++) ) return false; return true; } i…
题目链接 题意:给你一棵无根树,每次你可以选择一个点从白点变成黑点(除第一个点外别的点都要和黑点相邻),变成黑点后可以获得一个权值(白点组成连通块的大小) 问怎么使权值最大 思路:首先,一但根确定了,整棵树的权值就只需要模拟即可,所以思路就转换为求哪一个点为根的权值最大. 这题需要用到一个二次扫描换根的思想,我们可以先从任意一个点去进行树形dp 并且得到从这个点开始去逐渐更新他的儿子节点 #include<cstdio> #include<cstring> #include<…
Educational Codeforces Round 69 (Rated for Div. 2) D. Yet Another Subarray Problem 题目链接 题意: 求\(\sum_{i=l}^{r}-k\lceil\frac{r-l+1}{m}\rceil\)的最小值,\(n\leq 3*10^5,m\leq 10\). 思路: 因为\(m\)很小,那么对于一段区间,中间部分可以划分为多个长度为\(m\)的区间,两端都长度不超过\(m\). 所以令\(dp(i)\)表示以\(…
Educational Codeforces Round 63 (Rated for Div. 2) D. Beautiful Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array aa consisting of nn integers. Beauty of array i…
Educational Codeforces Round 69 题解 题目编号 A B C D E F 完成情况 √ √ √ ★ ★ - D. Yet Another Subarray Problem 一个子数组的价值为: \[\sum_{i=l}^{r} a[i] - k\lceil{\frac{r-l+1}{m}}\rceil\] 求解其最大值.子数组可以为空,此时价值为0. \(r-l+1\)自然是子数组的长度\(len\),可以发现每当\(len\)增加\(m\)后,\(\lceil{\…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…