CodeForces
文章平均质量分 81
saragrean
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #328 (Div. 2)
【A. PawnChess】【B. The Monster and the Squirrel】正n变形,顶点顺时针标记为1~n,从1开始画对角线,如果在画一条对角线时要跟另一条对角线交叉,那么就不要延伸出去,与另一条对角线相交于一点就好问你在这个正n变形里面有几块空间通过画图找规律可以知道是(n-2)*(n-2)【C. The Big Race】W跟B这两个人走一步原创 2015-11-01 21:54:04 · 479 阅读 · 0 评论 -
Codeforces Round #223 (Div. 2) D
【D. Sereja and Tree】一棵树的特点就是当节点是2^x时,它就有两个儿子,否则就只有一个儿子输入n,表示树有n层,即深度是n,接下来是m次询问(一开始是一棵空树)每次输入有两种操作1、1 t l r x => 第t层的第l个节点到第r个节点之间的值是x2、2 t v => 求第t层第v个数的子树中包含的不同的值的个数先预处理出每个节点后面的左二子原创 2015-11-23 20:54:53 · 306 阅读 · 0 评论 -
codeforces 606D. Lazy Student(#335 逆最小生成树)
题目链接:【codeorces 606D】#include #include #include #include #include using namespace std;#define inf 100010#define ll __int64int link[inf], vis[inf];struct node{ int w, id;}a[inf], b[inf];原创 2015-12-10 23:00:13 · 602 阅读 · 0 评论 -
codeforces 589C Polycarp's Masterpiece(分治 折半搜索)
【2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)】给你一个字符串s, n次操作,每次把最后一个字母放到最前面放k次, 得到一个新的字符串,把新的字符串添加到原来的字符串的后面m次询问,问你在l~r之间字母c出现的次数是多少原创 2015-11-26 22:28:49 · 516 阅读 · 0 评论 -
codeforces 381E Sereja and Brackets(线段树)
题目链接:【E. Sereja and Brackets】 线段树输入一串括号串,m次询问,每次输出区间[l,r]之间配对的括号最多是多少配对的括号是‘()’,除此之外全不是配对的a[i]表示到i为止一共有多少括号对b[i]表示到i为止有多少‘(’没有配对先遍历一遍,记录数组a,b,那么区间[l,r]的括号对数就是a[r] - a[l-1] - numnum就是在'(原创 2015-11-29 20:02:31 · 359 阅读 · 0 评论 -
codeforces 600C. Make Palindrome(贪心)
题目链接:【C. Make Palindrome】Educational Codeforces Round 2输入一串字符串,用最少的步数把它变成回文串,得到的回文串字典序最小先改变一些字母,然后改变顺序,改变顺序不算步数回文串的特点是左右对称,当长度是偶数时,串上的字母的个数全都是偶数个,当长度是奇数时,串上字母有且仅有一个是奇数个所以我们可以先用数组num[]记录字符串原创 2015-11-30 19:44:38 · 530 阅读 · 0 评论 -
codeforces 600E. Lomsat gelral(教育场 树形dp)
题目链接:【E. Lomsat gelral】一棵树有n(1一棵树的控制颜色的定义:在节点k的子树中,不存在另一种颜色出现的总次数大于颜色ci,那么ci就是以k为根的树的控制颜色,也就是说一棵树可以有多个控制颜色求以节点v为根的树的控制颜色总和样例41 2 3 41 22 32 4这一题难点以及特点就是向上一层递归时要用map[ i ][ ci ][ num原创 2015-12-02 14:58:11 · 835 阅读 · 0 评论 -
codeforces 380D. Sereja and Cinema(#223div1 组合数学)
题目链接:【D. Sereja and Cinema】电影院有n个位置,每个位置两边都有一个放东西的地方,当一个人进来之后他会立即占有位置两边空着的储物格,要是他到的时候,座位的两边的储物格都已经被占有了,那这个人就会离开输入n(1样例:60 1 0 0 0 6有一种情况绝对会有一个人会离开,a,b,c位置相邻,对应的进入顺序是ai,bi,ci,如果bi比ai,ci都大原创 2015-12-02 19:37:33 · 448 阅读 · 0 评论 -
codeforces 603A. Alternative Thinking(数学找规律 或者 dp)
题目链接:【A. Alternative Thinking】输入一串长为n的01串,翻转其中的一段,所谓的翻转就是0变1,1变0,求最终最长01交替的序列长度样例1:10000011 翻转后得到 10100011 最终的长度就是5 (红色部分)方法一:数学找规律原先相邻的变化后仍然相邻,所以我们可以先算出原本就相邻的最长是多少,一个子串翻转后,我们的要求是最长交替01串原创 2015-12-03 20:23:16 · 971 阅读 · 0 评论 -
Codeforces Round #262
div. 2【A. Vasya and Socks】#include using namespace std;int main(){ int n,m; scanf("%d%d", &n, &m); int last=0; int ans=0; while(n) { n--; last++; ans++; if(last == m) { last原创 2015-10-30 21:32:03 · 357 阅读 · 0 评论 -
Codeforces Round #322 (Div. 2)
【A. Vasya the Hipster】#include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long ll;const int N =原创 2015-10-26 21:21:16 · 363 阅读 · 0 评论 -
Codeforces Round #329 (Div. 2)
【A. 2Char】在n个字符串中,任选x个组成一长串,最终得到的长串最多由两个字母组成问最终得到的长串的最大长度是多少两个for循环,26个字母两两组合【B. Anton and Lines】直线的方程式是y = k*x+b输入x1, x2以及n个直线方程式的k,b问x1 y1 = k1*x1+b1 y2 = k1*x2+b1y1' = k2*x1+b2原创 2015-11-05 20:32:58 · 380 阅读 · 0 评论 -
Codeforces Round #323
div. 2【A. Asphalting Roads】#include #include int h[100],v[100];int k[3000];int main(){ int n; memset(h,0,sizeof(h)); memset(v,0,sizeof(v)); scanf("%d",&n); int flag=0,l=0; for(int i=1;i原创 2015-10-26 21:12:55 · 407 阅读 · 0 评论 -
Codeforces Round #324
这一场就只有div. 2,没有div. 1【A. Olesya and Rodion】#include #include #include #include #include using namespace std;int main(){ int n,m; scanf("%d%d",&n,&m); if(n==1 && m==10) { printf("-1\n原创 2015-10-26 21:04:22 · 262 阅读 · 0 评论 -
Codeforces Round #321 (div. 2)
【Codeforces Round #321 (Div. 2)】A. Kefa and First Steps原创 2015-09-24 22:07:15 · 368 阅读 · 0 评论 -
Codeforces Round #326
div. 2【A. Duff and Meat】【B. Duff in Love】【C. Duff and Weight Lifting】【D. Duff in Beach】【E. Duff in the Army】【F. Duff in Mafia】div. 1【E. Duff as a Queen】【F原创 2015-10-26 20:47:21 · 378 阅读 · 0 评论 -
Codeforces Round #325
div. 2【A. Alena's Schedule】#include #include #include #include #include using namespace std;int main(){ int a,n,flag=0,ff=0,ans=0; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a原创 2015-10-26 20:54:16 · 214 阅读 · 0 评论 -
Codeforces Round #327
div. 2【A. Wizards' Duel】【B. Rebranding】【C. Median Smoothing】【D. Chip 'n Dale Rescue Rangers】【E. Three States】div. 1【D. Top Secret Task】【E. Birthday】原创 2015-10-26 20:28:56 · 292 阅读 · 0 评论 -
Educational Codeforces Round 1
【A. Tricky Sum】【B. Queries on a String】【C. Nearest vectors】【D. Igor In the Museum】【E. Chocolate Bar】【F. Cut Length】原创 2015-11-14 20:27:51 · 373 阅读 · 0 评论 -
codeforces 380E. Sereja and Dividing(#223div1)(易超时巧妙求和)
题目链接:【E. Sereja and Dividing】输入大小为n的数组b[n],求ans = 函数g([b[i],b[i+1],b[i+2],b[i+3]……b[j] ],x)的意思是先从从i~j中选一个数k,然后计算 tmp=(b[k]+x)/ 2,x=tmp,b'[k] = tmp,i~j每一个都选过去之后能得到的最大的b'[]最直接的方法就是将i~j之间的b从小到大排序,原创 2015-12-04 21:38:18 · 478 阅读 · 0 评论