CF #324 DIV2 E题】的更多相关文章

这题很简单,把目标位置排序,把目标位置在当前位置前面的往前交换,每次都是贪心选择第一个满足这样要求的数字. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int MAX=2005; int p1[MAX],p2[MAX],mp[MAX]; int p…
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAX=1e5+7; char s1[MAX],s2[MAX],s3[MAX]; char getdif(char a,char b){ for(int i=0;i<26;i++) if('a'+i!=a&&'a'+i!=…
可以知道,当T较大时,对于LIS,肯定会有很长的一部分是重复的,而这重复的部分,只能是一个block中出现次数最多的数字组成一序列.所以,对于T>1000时,可以直接求出LIS,剩下T-=1000直接求出现次数最多的数字的个数即可.其实可以不用到1000,只需到n即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <v…
D. Tree Requests time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the…
cf 442 div2 F. Ann and Books(莫队算法) 题意: \(给出n和k,和a_i,sum_i表示前i个数的和,有q个查询[l,r]\) 每次查询区间\([l,r]内有多少对(i,j)满足l <= i <= j <= r 且 sum[j] - sum[i-1] = k\) 思路: 区间左右端点的挪动对答案的贡献符合加减性质,直接用莫队算法即可 复杂度\(O(n * sqrt(n) * log(maxsum))\) 过高 考虑先离散化预处理出所有位置 将\(log\)去…
A题: 贪心水题,注意1,1这组数据,坑了不少人 #include <iostream> #include <cstring> using namespace std; int main() { int a1,a2; while(cin>>a1>>a2) { int i=0; int b = max(a1,a2); int s = min(a1,a2); if(b==1 && s==1) { cout<<0<<endl…
A I'm bored with life 水题 #include<bits/stdc++.h> using namespace std; typedef long long int LL; const LL N=1,M=1,MOD=1; int main() {//freopen("t.txt","r",stdin); ios::sync_with_stdio(false); LL a,b; scanf("%I64d%I64d",&…
A Mister B and Book Reading  O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef long long int LL; const LL N=1,M=1,MOD=1; int main() {//freopen("t.txt","r",stdin); int c,v0,v1,a,l; scanf("%d%d%d%d%d",&c,&…
A Karen and Morning 水题 注意进位即可 #include<bits/stdc++.h> using namespace std; typedef long long int LL; int a,b; bool pal() { if((a%10)==(b/10)&&(a/10)==(b%10))return true; else return false; } void add() { b+=1; while(b>=60)b-=60,a+=1; whil…
A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300],b[300],n,k; bool cmp(int a,int b) { return a>b; } int main() {//freopen("t.txt","r",stdin); scanf("%d%d",&n,&k); f…
A Sagheer and Crossroads 水题略过(然而被Hack了 以后要更加谨慎) #include<bits/stdc++.h> using namespace std; int main() { //freopen("t.txt","r",stdin); int a[4][4]; //memset(a,0,sizeof(a)); for(int i=0;i<4;i++) for(int j=0;j<4;j++) scanf(&…
A. Vladik and Courtesy 水题略过 #include<cstdio> #include<cstdlib> #include<cmath> using namespace std; typedef long long int LL; int main() { LL a,b; scanf("%I64d%I64d",&a,&b); LL num=1; while(true) { if(a<num){printf(&…
A Okabe and Future Gadget Laboratory 暴力 #include<bits/stdc++.h> using namespace std; typedef long long int LL; const LL N=51,M=1,MOD=1; int num[N][N]; int main() { ios::sync_with_stdio(false); //freopen("t.txt","r",stdin); int n;…
C. Vasya and String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output ->  Link  <- 题目就不贴出来了,链接在上面: 题意:给定n,k,然后是一个长度为n的只含字母a.b的字符串,问至多改变k次使得一个子串字母都相同且长度最大,如所给样例: input 10 1 bbabbabbba output…
LINK:Drazil Likes Heap 那天打CF的时候 开场A读不懂题 B码了30min才过(当时我怀疑B我写的过于繁琐了. C比B简单多了 随便yy了一个构造发现是对的.D也超级简单 dp了一下就没了. 但是到E就只剩下30min(都怪A B浪费我过多时间. 观察题目中给的一个程序 其维护了一个大根堆且这个程序意思是一个函数 这个函数是指对于这个大根堆上的一个非空节点来说每次会将这个值给删掉继承最大的儿子值 然后递归值最大的儿子值得某个节点没有一个非空儿子(那么这个点的值被删掉为0.…
A. Jumping Ball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. T…
C题就是个dp,把原数据排序去重之后得到新序列,设dp[i]表示在前i个数中取得最大分数,那么: if(a[i] != a[i-1]+1)   dp[i] = cnt[a[i]]*a[i] + dp[i-1]; else      dp[i] = dp[i] = max(dp[i-1],a[i]*cnt[a[i]] + dp[i-2]),    dp[i-1]表示不取a[i], a[i]*cnt[a[i]] + dp[i-2]表示取a[i]. cnt[a[i]]是a[i]出现的次数. #incl…
水题,扫描一遍看是否出现价格低质量高的情况. #include<cstdio> #include<string> #include<vector> #include<cstring> #include<iostream> #include<algorithm> using namespace std; struct Node{ int a, b; Node(int a, int b){ this->a = a; this->…
题目链接: http://codeforces.com/problemset/problem/332/C 题目意思: 有n个命令,要通过p个,某主席要在通过的p个中选择k个接受. 每个任务有两个值ai,bi, ai表示如果该主席接受该命令,她的头发变灰的数量,bi表示如果该主席不接受该命令时,议员不高兴值. 对于通过的p个命令,该主席要使议员的不高兴值和最小,在相同的情况下,要使自己的头发变灰的数量尽可能的少. 让你求出通过哪p个命令,使得该主席的头发变灰的数量最多,在相同的情况下,输出使议员不…
C. Woodcutters time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immedi…
题目链接:http://codeforces.com/contest/707/problem/A A. Brain's Photos time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Small, but very brave, mouse Brain was not accepted to summer school of y…
http://codeforces.com/contest/299/problem/C 题目大意: 给两个0,1串保证长度都是2*n(偶数),问,Yaroslav, Andrey按照顺序取,首先是yaroslav取,然后是andrey取,然后已经去过的pos就不能再取了.问取到最后谁的值最大? 这是一题很简单的博弈题目...然而我竟然wa了好久. 思路 我们首先分析,当两者的某一个位置都有1的个数是多少. 如果是奇数,那么先手有优势,即可在11的位置上多取一个,而保证后手无法取到这个位置的1.那…
A 水题一道. 题目的大致意思就是:给你两个集合,求集合间有多少数对和是奇数. 题解,开\(4\)个桶后,求一个\(min\)就可以了. #include <bits/stdc++.h> using namespace std; int n, m; int v1[4], v2[4]; int main() { scanf("%d%d", &n, &m); for (int i = 1, x; i <= n; i ++) scanf("%d&q…
A 判断下5个名字出现了几次.pre数据巨弱,就这么一水题在std测刷掉了非常多的人.. /** @Date : 2017-10-24 16:04:41 * @FileName: A.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/stdc++.h> #define LL lo…
F. Monkeying Around   维护点在多少个线段上 http://codeforces.com/gym/101350/problem/F 题意:有m个笑话,每个笑话的区间是[L, R],笑话种类有1e5,一开始所有猴子都在凳子上,听到一个笑话,就倒下,但是如果是听过的笑话,就重新回到凳子上.问最终有多少个猴子在凳子上. 相当于有1e5个线段,如果我们能知道第i个猴子,被多少个线段覆盖了,那么可以找出那些线段中的最后那一条,就是最后覆盖上去的那一条,那条线段是哪一个笑话,设为k,如果…
第一题没话说 智商欠费 加老柴辅导终于过了 需要在意的是数据范围为2的63次方-1 三个数相加肯定爆了 四边形的定义 任意边小于其余三边之和 换句话说就是 最长边小于其余三边之和 这样的话问题转化为 最长边依次减其余三边的结果是否小于等于0 还有一点是题目出现0边 即最小边不为0 想得太多反而把0也算为合法.... 问题只需要 sort一下 判断a[0]==0||a[3]-a[2]-a[1]-a[0]>=0 输出NO //存在0边且最大边大于其他边之和 第二题 好多种姿势 题目链接http://…
6月快要结束了 期末也过去大半了 马上就是大三狗了 取消了小学期后20周的学期真心长, 看着各种北方的学校都放假嗨皮了,我们这个在北回归线的学校,还在忍受酷暑. 过年的时候下定决心要拿块ACM的牌子,一直坚持刷题,这一个学期刷了200道吧,感觉还是小有收获.特别是Ural和Codeforces上的题,质量很高. 然后4月的校赛,5月的省赛,发挥的也一般,不过也没有太失常. 希望暑假的选拔赛能碰到有趣的队友 蛤蛤. 这两天各种考试,实在是太忙,看了一下edu24的题目,不是很容易,做了一道水题,以…
A DZY Loves Hash 水题 #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> using namespace std; bool f[300]; int main() { long long int p,t; int i,j,k,m,n; cin>>p>>n; bool fs=0; memset(f,0,sizeof(f)); f…
两题都不难. 对于D题,可以使用相对移动,把吹aircraft移动变成相反方向的待援点的移动.假设此时时间为t,把aircraft的速度设为Vmax,看待援点在飞船最大速度飞行t秒的范围内,注意风向变化的时间点即可.其实很明显的二分.. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int x1,y1,x2,…
题目地址:http://codeforces.com/contest/460/problem/B 这题乍一看没思路.可是细致分析下会发现,s(x)是一个从1到81的数,不管x是多少.所以能够枚举1到81,这样就转化成了一个一元一次方程.直接求解x就能够了.这时候还要推断x是否在1到10^9之间,而且它的各位数之和是s(x). 这题脑残了两次.. . 第一次是写成了<=10^9..然后发现错误后,就又改了回来. .可是发现10^9是不可能的,. ... 代码例如以下: #include <ios…