CF778A(round 402 div.2 D) String Game】的更多相关文章

题意: Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t an…
D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty…
D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty…
D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty…
二分要删除几个,然后暴力判定. #include<cstdio> #include<cstring> using namespace std; int a[200010],n,m; char s1[200010],s2[200010]; bool cant[200010]; bool check(int x) { memset(cant,0,sizeof(cant)); for(int i=1;i<=x;++i) cant[a[i]]=1; int j=1; for(int…
Codeforces Round #402 (Div. 2) A. Pupils Redistribution 模拟大法好.两个数列分别含有n个数x(1<=x<=5) .现在要求交换一些数使得两个数列含有某个数字的个数相同,求最少交换次数. int v1[N],v2[N]; int main() { int n; while(~scanf("%d",&n)) { int x; memset(v1,0,sizeof(v1)); memset(v2,0,sizeof(v…
Codeforces Round #402 (Div. 2) A. 日常沙比提 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; inline int read(){ ,f=; ; c=getchar();} +c-'; c=getchar();} return x*f; }…
题目链接:BestCoder Round #81 (div.2) 1003 String 题意 中文题,上有链接.就不贴了. 思路 枚举起点i,计算能够达到k个不同字母的最小下标j,则此时有子串len-j个. 将全部起点的值加起来即是结果. 代码 #include<iostream> #include<algorithm> #include<vector> using namespace std; #define LL long long const int MOD =…
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In hig…
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In hig…
Problem A: 题目大意: 给定两个数列\(a,b\),一次操作可以交换分别\(a,b\)数列中的任意一对数.求最少的交换次数使得任意一个数都在两个序列中出现相同的次数. (\(1 \leq a_i,b_i \leq 5 , 1 \leq n \leq 100\)) 题解: 直觉告诉我这么搞就行了 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typed…
2017.2.26 CF D2 402 这次状态还算能忍吧……一路不紧不慢切了前ABC(不紧不慢已经是在作死了),卡在D,然后跑去看E和F——卧槽怎么还有F,早知道前面做快点了…… F看了看,不会,弃 E看了看,不会,弃 D看了看,不会……没法再弃了.想了好久发现可以二分答案(浪费30min) 过了D以后去看F,发现果然还是不会(浪费20min) 之后看E,思路跑偏浪费20min+ 此时时间还剩大约20min,终于想到了E可能是正解的做法,开始拼手速,各种调试,终于调过了样例,而时间只剩10s了…
Description Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k. In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10k. For example, if k = 3, in the…
题意: Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k. In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10k. For example, if k = 3, in the number 3…
A题卡壳了,往离线倒着加那方面想了会儿,后来才发现方向错了,二十多分钟才过掉,过了B后做D,想法好像有点问题,最后只过两题,掉分了,差一点回紫. AC:AB Rank:173 Rating:2227-23->2204 A.String Game 题目大意:给出字符串A和B,保证B是A的子序列,给出一个长度为A串长度的排列,问按排列的顺序删掉A串中字符,最多删几个使得B任然是A的子序列.(A串长度<=200,000) 思路:发现答案满足单调性,二分删几个,O(n)check一下B还是不是A的子序…
哎,今天第一次打div1 感觉头脑很不清醒... 看到第一题就蒙了,想了好久,怎么乱dp,倒过来插之类的...突然发现不就是一道sb二分吗.....sb二分看了二十分钟........ 然后第二题看了一下,感觉太码农了不可做,然后就cd逛一逛. 突然觉得c可做,就做了一下,交上去wa了,发现有情况没考虑. 这下又滚回了b,结果又没写完...... gg  2040 -83 ->1957 -----------------------------------------------我似分割线啊 A…
题目链接:http://www.codeforces.com/problemset/problem/118/A题意:字符串转换……C++代码: #include <string> #include <iostream> using namespace std; string s; bool _in(char c, string s) { ; i < s.length(); i ++) if (c == s[i]) return true; return false; } in…
按位考虑,每个变量最终的赋值要么是必为0,要么必为1,要么和所选定的数相同,记为2,要么和所选定的数相反,记为3,一共就这四种情况. 可以预处理出来一个真值表,然后从前往后推导出每个变量的赋值. 然后从高位到低位考虑,如果某一位,对于所有变量而言,2的数量大于等于3的数量,就把所选定的数的该位记为0,否则记为1,就能满足和最小.反之就能满足和最大. #include<cstdio> #include<string> #include<iostream> #include…
暴搜 #include<cstdio> #include<algorithm> using namespace std; int n,K,Div=1,a[21],m,ans=100; bool vis[21]; void calc(int now) { int t=0; bool flag=0; for(int i=m;i>=1;--i) if(!vis[i]) { if((!flag) && a[i]==0) return; t=t*10+a[i]; fla…
Description Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the w…
Description Igor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor knows about each item that its price now is ai, and after a week of discounts its price will be bi. Not all of sellers are…
题意: Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game. Initially, Bob chooses integer m, bit depth of the game, which means that all numbers in the game will consis…
D. String Game Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya th…
总体思路好想,就是在找K个不同字母的时候,卡时间. 看了大神代码,发现goto的!!!!998ms #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<queue> #include<stack> #include<cmath> #include<algorithm> #include<mallo…
这一场的表现可以用"全程智障"4个字,生动传神地描述出来. About 写题: A. 写了一堆if比较大小, 这很勤勉.(绝对值君对自己の存在感为0表示很难过.) B. 题,直接读错...对着第二个样例疯狂思考人生. C. 又写出一堆划水的if.没必要的分类讨论太多. D. 搞这个题时,我表现得相当活跃,忽而写dp, 忽而写set,忽而用set维护dp. 代码突突突了150+行,成功地把一个二分答案的水题,搞得跟div1E一样. About 技能: 1. 尺取二分得加技能点啦! 2.…
按照b[i]-a[i],对物品从大到小排序,如果这个值大于零,肯定要立刻购买,倘若小于0了,但是没买够K个的话,也得立刻购买. #include<cstdio> #include<algorithm> using namespace std; struct Point { int x,y; }a[200010]; int n,K,ans; bool cmp(const Point &a,const Point &b) { return a.y-a.x>b.y-…
一次交换,会让Group A里面的某个数字的数量-1,另一个数字的数量+1:对Group B恰好相反. 于是答案就是xigma(i=1~5,numA[i]-numB[i]>0)(numA[i]-numB[i])/2,如果这个值无法被2整除,则无解,或者如果这个值不等于xigma(i=1~5,numA[i]-numB[i]<0)(-numA[i]+numB[i])/2的话,也无解. 或者如果某个值在两组中出现的总次数无法被2整除,也无解. #include<cstdio> using…
好长时间没有打Codeforces了,今天被ysf拉过去打了一场. lrd也来参(nian)加(ya)比(zhong)赛(sheng) Problem A: 我去,这不SB题吗.. 用桶统计一下每个数出现的数目. 对位相减然后除二加起来 最后除二输出就行了. 具体为什么我也没想,直觉告诉我这么做就可以了. 然后他就pretest passed了 Problem B: for循环到k扫一遍就行了吧. 立马写了个上去 Wrong answer on pretest 2 没开long long !!!…
题目地址:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=691&pid=1003题意:找出一个字符串满足至少有k个不相同的字母的字串的个数可以注意到 如果 i到j 是满足条件的 则 i到j+1,j+2...n都是满足的,所以可以用尺取法,每次找到满足条件最短的 i,j 然后每次都加上 n-j+1就是答案 #include<bits/stdc++.h> #define inf 0x3f3f3f3f ; u…
Description In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An a…