Codeforces Round #390 (Div. 2) A B C D】的更多相关文章

http://codeforces.com/contest/754/problem/D 题意: 给定几组区间,找k组区间,使得它们的公共交集最大. 思路: 在k组区间中,它们的公共交集=k组区间中右端点最小值-k组区间中左端点最大值.如果我们要区间大,那我们应该尽量让左端点小,右端点大. 先对区间按照左端点排序,然后用优先队列处理. 将区间按照左端点从小到大的顺序一一进队列,只需要进右端点即可,如果此时队列内已有k个数,则队首就是这k组区间的最小右端点,而因为左端点是从小到大的顺序进队列的,所以…
http://codeforces.com/contest/754/problem/C C. Vladik and chat time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Vladik discovered a new entertainment — coding bots for social netwo…
http://codeforces.com/contest/754/problem/A 题意: 给出一串序列,现在要把这串序列分成多个序列,使得每一个序列的sum都不为0. 思路: 先统计一下不为0的数,只要有一个不为0的数,那么就能分割. 如果一个数不为0,则让它单独成为一组,如果它后面有0,则把它后面的连续的0也归到这一组中. 特别要注意一下的是,序列一开始就是0的情况. #include<iostream> #include<algorithm> #include<cs…
时隔一个月重返coding…… 期末复习了一个月也不亏 倒是都过了…… 就是计组61有点亏 复变68也太低了 其他都还好…… 假期做的第一场cf 三道题 还可以…… 最后room第三 standing383简直人生巅峰…… 看楼上楼下都是两道题的 如果A题不错那么多估计能进前300了吧…… 这场倒是把之前两场的分加回来了 开头不错 这个假期争取紫名~ A.Lesha and array splitting 把给定的数组分割成几个区间 要求各个区间和不能为0 一开始没注意到分割之后的区间重新合成之…
题意就是一个给出2个字符矩阵,然后进行匹配,输出每个位置的匹配的结果 (超出的部分循环处理) 一种做法是使用fft,比较难写,所以没有写 这里使用一个暴力的做法,考虑到一共只出现26个字符 所以使用一个数组G[c][i][j]表示字符c是否出现在位置(i, j),即G[c]是一个01矩阵 可以使用bitset定义G 然后考虑匹配的时候 考虑要匹配的那个矩阵B,如果当前字符是?就跳过 如果不是,就考虑这个字符会对哪些匹配位置造成影响 用bitset表示一行的状态,然后使用and和左移.右移就可以更…
这是一场比较难的div2 ... 比赛的时候只出了AB A很有意思 给出n个数 要求随意的把相邻的数合并成任意多数 最后没有为0的数 输出合并区间个数与区间 可以想到0可以合到任何数上并不改变该数的性质 所以如果不全是0 最后一定是有答案的 把所有的0都合并到最近的非0数上去 非0数不变 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #include<…
All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goods in the supermarket have unique integer ids. Also, for every integer there is a product with id equal to this integer. Fedor has …
Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game when…
One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha decided to split the array A into several, possibly one, new arrays so that the sum of elements in each of the new arrays…
A. Lesha and array splitting 水题模拟.(0:10) 题意:给你一个n个元素的数组,求能否把这个数组分成若干连续小段,使得每段的和不为0.如有多种解输出任意一个. 思路:搞一个前缀和,如果这个数列的和不为0那么就直接输出一个区间左为1右为n.如果数列和为0那么找一个点前面的和不为0且后面的和也不为0,直接输出这两个区间. int a[N],sum[N]; int main() { int n; while(~scanf("%d",&n)) { mem…