D2. Great Vova Wall (Version 2)】的更多相关文章

传送门:http://codeforces.com/contest/1092/problem/D2 D2. Great Vova Wall (Version 2) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vova's family is building the Great Vova Wall (named by Vo…
http://codeforces.com/contest/1092/problem/D2 Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The cur…
l链接 [https://codeforces.com/contest/1092/problem/D2] 题意 和D1一样只是不能竖直放了 分析 水平放的话,就只可能是相邻等时才可以,而且你会发现 只有中间数字小于两边的才可以 比如551122是可以的,15522不可以,你用一个栈保存当前不能改变高度的位置 如果遇到相等的就出栈,具体看代码体会吧 代码 #include<bits/stdc++.h> using namespace std; int main(){ int n,h; //fre…
题意: 给一排砖,每列的高度$a_i$,问是否可以放1*2的砖,使得n列高度一样,砖只能横着放 思路: 每两个相邻的高度相同的砖可以变成大于等于它的高度的任意高度 所以像这样的 123321 是不满足题意的,因为两边的相同的高度没法合在一起 只有像这样的 321123 才满足 所以,满足题意的墙应该像上述一样几个“凹”的高度的组合加上最多一列高度为h的墙 这个h应该满足h<=max(a),准确来说应该是等于 拿栈搞一搞就行了 代码: #include<iostream> #include…
传送门:http://codeforces.com/contest/1092/problem/D1 D1. Great Vova Wall (Version 1) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vova's family is building the Great Vova Wall (named by Vo…
http://codeforces.com/contest/1092/problem/D1 Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The cur…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. N…
链接 [https://codeforces.com/contest/1092/problem/D1] 题意 给你n个位置墙的高度,现在你有2×1 砖块,你可以竖直或者水平放置 问你是否可以使得所有位置高度一样 思路 都在代码里,看了你就恍然大悟了...仔细想想 代码 #include<bits/stdc++.h> using namespace std; int main(){ int n,h; ios::sync_with_stdio(false); cin.tie(0); cout.ti…
D1. Great Vova Wall (Version 1): 题意:给定长度为N的墙,以及每个位置的一些高度,现在让你用1*2的砖和2*1的砖去铺,问最后能否铺到高度一样. 思路:分析其奇偶性,在一个位置加1*2的砖,其奇偶性不变.在相邻的而且高度相同的位置加2*1的砖,两个奇偶行都改变.那么我们不需要保存高度,因为高度我们可以加1*2的砖,使他们等效到奇偶性的高度:所以只需要保存奇偶,然后加入栈中,如果栈顶的两个元素相同,则可以消去,最后如果栈元素<=1,则ok. (如果最后栈为空,说明最…
D2. Optimal Subsequences (Hard Version) This is the harder version of the problem. In this version, 1≤n,m≤2⋅105. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems. You are given a seque…
D2. RGB Substring (hard version) inputstandard input outputstandard output The only difference between easy and hard versions is the size of the input. You are given a string…
一.题目 D2. RGB Substring (hard version) 二.分析 思路一开始就想的对的,但是,用memset给数组初始化为0超时了!超时了! 然后我按照题解改了个vector初始化,就过了! 以后得谨慎使用memset了. 三.AC代码 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 #define ll long long 5 #define Min(a,b) (a)>(b)?(b):(a) 6 const…
D1. RGB Substring (easy version) time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The only difference between easy and hard versions is the size of the input. You are given a string s consistin…
题目链接:https://codeforces.com/contest/1262/problem/D2 将数组按大到小排序(相同大小的按下标由小到大排序),依次将排序后的每个数在原数组中的位置放入主席树. 对于每个询问的k,pos 输出原数组中下标为query(T[0],T[k],1,len,pos)所对应的数字即可 #include<iostream> #include<cstdio> #include<algorithm> using namespace std;…
This is the hard version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task. You are given a string ss, consisting of lowercas…
题意:一共有$n$个数,$m$次询问,每次询问包括$k.pos$两个数,需要你从这$n$个数里面找出$k$个数,使得他们的总和最大,如果有多种情况,找出序号字典序最小的一组,然后输出这个序列中第$pos$个数的值. 思路:根据贪心的思想,把这$n$个数按大到小排个序$($相同大小按下标从小到大$)$,再按照每个元素的下标依次放入主席树中,对于每次询问,查找前$k$个数中第$pos$大的数,但这个查找到的值是下标,再把这个下标对应到数值即可,体现在代码中的$b[]$数组中. #include <i…
题意: 取一字符串不相交的前缀和后缀(可为空)构成最长回文串. 思路: 先从两边取对称的前后缀,之后再取余下字符串较长的回文前缀或后缀. #include <bits/stdc++.h> using namespace std; string Manacher(const string &s){ string t="#"; for(char c:s) t+=c,t+="#"; int RL[t.size()]={0}; int MaxRight=…
传送门 题意: 给你一个长为n的仅由'R','G','B'构成的字符串s,你需要在其中找出来一个子串.使得这个子串在"RGBRGBRGBRGB........(以RGB为循环节,我们称这个串为str)"里面也是一个子串,这个子串的长度是k 可是有可能s字符串中找不到,那么这个时候就可以改变s字符串中某些位置的字母来完成任务.问最少需要改变多少个字母 题解: 主要看暴力的姿势对不对.在上一道的D1上面,我是对s字符串的每一个位置进行'R','G','B'的枚举,因为如果这个子串也是str…
一场div3... 由于不计rating,所以打的比较浪,zhy直接开了个小号来掉分,于是他AK做出来了许多神仙题,但是在每一个程序里都是这么写的: 但是..sbzhy每题交了两次,第一遍都是对的,结果就涨了.. A - Uniform String 没什么意思.. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<set> #inclu…
Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入n,k,n表示字符串的长度,k表示从1-k的小写字符(1即是a),现在要求最大化最少字符的数量. 题解: 贪心搞一搞就行了. 代码如下: #include <bits/stdc++.h> using namespace std; int T; int n,k; int main(){ cin>…
gcc交叉编译时发生这种错误 /.. .../voice_demo: hidden symbol `pthread_atfork' in /opt/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/../aarch64-linux-gnu/libc/usr/lib/aarch64-linux-gnu/libpthread_nonshared.a(pthread_atfork.oS) is referenced by DSO 调用关系如下: A-…
SVN命令参考:   https://www.cnblogs.com/wlsxmhz/p/5775393.html 我们需要明白命令行设置忽略文件和文件夹是通过设置svn:ignore属性设置的,propset(ps,pset)用于设置属性的值,propget(pg,pget)用于获取属性的值.用法如下: svn pg svn:ignore   #获取属性值 svn ps svn:ignore 'value' path  #设置属性值 一.忽略单个目录 1.我们创建一个文件夹并且忽略该文件夹;…
本蒟蒻已经掉到灰名了(菜到落泪),希望这次打完能重回绿名吧...... 这次赛中A了三题 下面是本蒟蒻的题解 A.Three Piles of Candies 这题没啥好说的,相加除2就完事了 #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll q; scanf("%lld",&q); while(q--) { ll a,b,c; scanf("…
Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) D2 - Optimal Subsequences (Hard Version) 这是一个发挥想象力的题,可以离线,询问区间[1,r]的第k大.在线的话就是一个主席树的裸题,当然用可持久化平衡树也可以做. 离线之后,可以在线段树上二分或者在树状数组上二分.…
// 比赛链接:https://codeforces.com/contest/1196 // CF 2019.7.24 // 本想Div3手速场上分,结果卡在C题,掉了不少分. // 自闭了这么久,今天补题,吸取教训. A - Three Piles of Candies 题意: 比赛时候看了半天也没看明白,真是sb了. Alice与Bob要把三堆糖果尽可能地平分,两人轮流拿,最后一个拿的要保证两人一样多.否则的话如果最后谁多了就要扔掉,直到两人拿的糖果数量相等. 给定三堆糖果初始数量,求他们能…
比赛链接:https://codeforc.es/contest/1196 A. Three Piles of Candies 题意:两个人分三堆糖果,两个人先各拿一堆,然后剩下一堆随意分配,使两个人中最后糖果较少的那个人的糖果最多. 分析:水题. AC代码: #include <bits/stdc++.h> #define SIZE 300007 #define rep(i, a, b) for(int i = a; i <= b; ++i) typedef long long ll;…
A. Bad Ugly Numbers 思路 题意: 给我们一个k,让我们用 0-9 之间的数字构成一个 k位数a,a不能被组成a的每一位数字整除. 分析:首先 k等于1,无论我们怎么配都会被整除:当k > 1 的时候,a的组成位数中肯定不能有1,那么只能在 2-9,之间选择,剩下我们可以选择两个不能互相整除的数如 2.7,,我们可以让2作为第一位,剩下的位数全是7,,,,例如我们求一个k = 3 时我们构成的数a,a = 277 代码 #include<iostream> #inclu…
题目链接: D2. The Wall (medium) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Heidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, forming groups, preparing their…
D2. The World Is Just a Programming Task (Hard Version) This is a harder version of the problem. In this version,…
D2. Remove the Substring (hard version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions is the length of the string. You are given a stri…