Codeforces Round #371 (Div. 2) C 大模拟】的更多相关文章

http://codeforces.com/contest/714/problem/C 题目大意:有t个询问,每个询问有三种操作 ①加入一个数值为a[i]的数字 ②消除一个数值为a[i]的数字 ③给一个字符串s,s中分别表示0和1,0表示目前该位为偶数,1表示目前该位为奇数.然后询问目前数组中和s每一位能匹配的个数.如果数组中目前的该数字比s的len要短,那么我们就在s的左边一直加0.如果数组中的目前的数字比s的len长,那么就在该数组的左边一直加0就好了.问能和s匹配的有几个,并输出 思路:我…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…
A. Snacktower 题目连接: http://codeforces.com/contest/767/problem/A Description According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct s…
http://codeforces.com/contest/713 题目大意:给你一个长度为n的数组,每次有+1和-1操作,在该操作下把该数组变成严格递增所需要的最小修改值是多少 思路:遇到这类题型,最普遍的方法就是把严格递增给变为递增就好了,所以我们对所有的a进行处理,a[i]-=i,然后再dp. 我们对dp进行如下的定义:定义dp[i][j],dp[i][j]表示前i个数,1~i-1个数的val都<=b[j],目前第i个数修改成b[j](即第j大的数),所需要的最小花费dp[i][j] =…
A. Combination Lock time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there…
A. Joysticks time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at…
https://codeforces.com/contest/1121/problem/D 题意 给你一个m(<=5e5)个数的序列,选择删除某些数,使得剩下的数按每组k个数以此分成n组(n*k<=m),存在只要一组满足和目标集合s(|s|<=k)匹配(即集合中存在的数,组内一定存在) 题解 重点:找出至少一组满足要求的数 假设[l,r]内满足要求,还需要满足:\((l-1)/k*k+(m-r)/k*k>=k*(n-1)\),可以用双指针,对于每个l可以处理出最小的r满足要求 这样…
题目链接:http://codeforces.com/contest/714/problem/C C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invited all her friends to…
题目链接:http://codeforces.com/problemset/problem/714/B 题目大意: 第一行输入一个n,第二行输入n个数,求是否能找出一个数x,使得n个数中的部分数加上x或部分数减去x ,n个数相等. 例如:5 1 3 3 2 1 输出: YES Init: x=1 情况,第一个数和最后一个数+x,第二三个数减去x ,则这n个数都为2(相等),故输出“YES” 解题思路: 对于刚才举的例子 可知 n个数只有三个元素 1 2 3 只要使得 2-1==3-2 即可满足条…
题目链接:http://codeforces.com/contest/714/problem/B 题意:给定一个长度为N的初始序列,然后问是否能找到一个值x,然后使得序列的每个元素+x/-x/不变,最后把序列变成各个元素都相等(序列每个元素只能进行操作一次) 思路:因为每个元素只能操作一次,而且操作的值只有一个值x.那么就可以发现当序列中存在3个以上的互不相等的数时一定不能构造要求的序列. 当序列存在3个一下的互补相同的数时,一定能构造要求的序列.现在要考虑的是刚刚有3个互不相同的序列时,把序列…
题目链接:http://codeforces.com/contest/714/problem/A 题意:有两个人A,B 给定A的时间区间[L1,R1], B的时间区间[L2,R2],然后在正好K分钟的时候A小时一分钟,即K这一分钟A不在.现在问A和B在时间上能相遇多久. 思路:相遇的区间是[max(L1,L2),min(R1,R2)],然后判断K是否在这个区间里就好了. 还有可能相遇的区间大小为负数即A和B不相遇 #define _CRT_SECURE_NO_DEPRECATE #include…
链接:http://codeforces.com/contest/404/problem/B B. Marathon time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valera takes part in the Berland Marathon. The marathon race starts at the stadium…
C. Bus time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches…
C. Sonya and Problem Wihtout a Legend 题目连接: http://codeforces.com/contest/713/problem/C Description Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing n positive integers. A…
D. Animals and Puzzle 题目连接: http://codeforces.com/contest/713/problem/D Description Owl Sonya gave a huge lake puzzle of size n × m to hedgehog Filya as a birthday present. Friends immediately started to assemble the puzzle, but some parts of it turn…
C. Sonya and Queries 题目连接: http://codeforces.com/contest/714/problem/C Description Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries,…
D. Searching Rectangles 题目连接: http://codeforces.com/contest/714/problem/D Description Filya just learned new geometry object - rectangle. He is given a field consisting of n × n unit cells. Rows are numbered from bottom to top with integer from 1 to…
B. Filya and Homework 题目连接: http://codeforces.com/contest/714/problem/B Description Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help. Filya is given an arra…
A. Meeting of Old Friends 题目连接: http://codeforces.com/contest/714/problem/A Description Today an outstanding event is going to happen in the forest - hedgehog Filya will come to his old fried Sonya! Sonya is an owl and she sleeps during the day and s…
B. Rebranding   The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for th…
http://codeforces.com/contest/1154/problem/E 解题: 举例n=10,k=1 1,2,10,4,7,6,9,8,5,3 第一次,1队先挑2,10,4这三个人 1,2,10,4,7,6,9,8,5,3 第二次,2队挑6,9,8三个人 1,2,10,4,7,6,9,8,5,3 第三次,1队挑1,7,5三个人 1,2,10,4,7,6,9,8,5,3 第四次,2队挑3一个人 1,2,10,4,7,6,9,8,5, 显然需要实现的有两点 (1)挑完后的“连接”,…
题意:有一组数,问子数组和最大不超过\(t\)的最多元素个数. 题解:用数组模拟队列,不断的往里面放,队列中的元素之和大于\(t\),就不断地从队头弹出直到满足条件,维护一个最大值即可. 代码: int n,t; int a[N]; int q[N]; int hh,tt=-1; int main() { //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); n=read(),t=read(); for(int i=1;i<=n;++i) a…
传送门  map或者字典数的应用 简单题 题意: 思路: AC代码: #include<iostream> #include<cstring> #include<cmath> #include<map> #include<algorithm> #include<cstdio> #define max(a,b) a>b?a:b #define F(i,a,b) for(int i=a;i<=b;i++) #define me…
E. Sonya and Problem Wihtout a Legend time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Sonya was unable to think of a story for this problem, so here comes the formal description. You are g…
C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multi…
B. Filya and Homework time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to com…
题目链接 分析:01trie树,很容易就看出来了,也没什么好说的.WA了一发是因为没有看见如果数字位数大于01序列的时候01序列也要补全0.我没有晚上爬起来打,白天发现过的人极多. /*****************************************************/ //#pragma comment(linker, "/STACK:1024000000,1024000000") #include <map> #include <set>…
C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multi…
D - Animals and Puzzle #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI pair<LL, int> #define ull unsigned long long using namespace std; + ; cons…
C - Sonya and Problem Wihtout a Legend 思路:感觉没有做过这种套路题完全不会啊.. 把严格单调递增转换成非严格单调递增,所有可能出现的数字就变成了原数组出现过的数字. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI…