Codeforces Round #282 (Div.1) Solution

上午考试,下去去参观教堂,回来睡大觉,搞到现在才有时间做,水平恢复中。

A 倒过来扫括号匹配很容易理解

B dp[i]表示最后一个拿到i的数目,sum[i]表示前i项dp和,sum2[i]表示前i项sum和。显然。dp[i]=sum2[o], o是最右边的坐标使得s[o+1,i]能包含t。

C Interesting,我建了个树,硬着dp搞得。。还没优化就46ms,想来这种题数据也不好构造。

D Editorial似乎说离线搞,不过我在线搞出来了。我存了每个节点子树平方和,子树和,整体和,整体平方和。询问的时候分类讨论一下u在子树内还是子树外就好了。http://codeforces.com/contest/494/submission/9375514

ps:感觉这场做得很顺啊,是主的庇护吗?因父,及子,及圣神之名,阿门。

时间: 2024-08-11 07:48:52

Codeforces Round #282 (Div.1) Solution的相关文章

Codeforces Round #282 (Div. 2) a

/**  * @brief Codeforces Round #282 (Div. 2) a  * @file a.cpp  * @author mianma  * @created 2014/12/15 9:55  * @edited  2014/12/15 9:55  * @type math  * @note  */ #include <fstream> #include <iostream> #include <cstring> using namespace 

Codeforces Round #282 (Div. 2) c

/**  * @brief Codeforces Round #282 (Div. 2) c  * @file c.cpp  * @author mianma  * @created 2014/12/16 16:09  * @edited  2014/12/16 16:09  * @type math  * @note  */ #include <fstream> #include <iostream> #include <cstring> #include <c

数学 Codeforces Round #282 (Div. 2) B. Modular Equations

题目传送门 题意:a % x == b,求符合条件的x有几个 数学:等式转换为:a == nx + b,那么设k = nx = a - b,易得k的约数(>b)的都符合条件,比如a=25 b=1,那么24,12, 8, 6, 4, 3, 2都可以,所以只要求出k的约数有几个就可以了,a <= b的情况要特判 /************************************************* Author        :Running_Time* Created Time  

Codeforces Round #282 (Div. 2) b

/**  * @brief Codeforces Round #282 (Div. 2) b  * @file b.cpp  * @author mianma  * @created 2014/12/15 9:55  * @edited  2014/12/15 9:55  * @type math  * @note  */ #include <fstream> #include <iostream> #include <cstring> #include <cma

Codeforces Round #275 (Div.1) Solution

好久没做题了,开场Virtual热热身. A 构造,我的方法是,取1,2,3...,k这几个差值,前k+1个数分别是 1, k+1, 2, k, ...., 之后就k+2, k+3, ..., n B 因为题设是与操作.我们按照每一位来,如果有一个限制某位是1,则将那段区间标志1,没有限制的位全部置零即可,然后检验为0的位是否全是1.标志一段区间可以用标记法,检验可以求和看差值. C 我做完之后看了CF tutorial 跟我的做法不同.我的做法比他给的复杂度低一点,不过题解好帅,而且跑出来速度

[比赛] Codeforces Round #538 (Div. 2) solution (贪心,数学其他,二分,线段树)

已经写了100篇题解啦! link solution pdf #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; inline int read(){ int f=1,ans=0;char c; while(c<'0'||c>'9'){if(c=='-')f=-1;c

Codeforces Round #607 (Div. 1) Solution

从这里开始 比赛目录 我又不太会 div 1 A? 我菜爆了... Problem A Cut and Paste 暴力模拟一下. Code #include <bits/stdc++.h> using namespace std; typedef bool boolean; const int N = 1e6 + 5; const int Mod = 1e9 + 7; int T; int x; int len; char s[N]; int paste(int s1, int t1, in

Codeforces Round #268 (Div. 1) solution

A.24 Game 题意:给你1, 2, ..., n-1, n 这个序列,每次你可以取出两个数做+/-/*三种操作之一,然后把结果放回到序列中,询问能否是的这个序列最后只剩下一个24. 解法:首先很明显n < 4的时候是无解的.如果n=4,那么1 * 2 * 3 * 4=24,如果n=5,那么(5 - 1 - 2) * 3 * 4 = 24.若n > 5,那么我可以做n - (n - 1) = 1,相当于变成了n-2时候的情况加一个1,那么显然最后让答案乘上这个1即可. 代码: includ

Codeforces Round #282 (Div. 2)

也是几百年没做CF咯,这场还是赛后做的,退化很多啦 A.Digital Counter 找规律 可能有火柴棍丢失,问你可能组成的数字有多少种,只需要肉眼看看每个数字填上火柴棍可能形成的数字,打个表就行了 #include <iostream> #include <cstdio> using namespace std; const int pos[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2}; int a, b; int main() { #ifdef LO