
易错
文章平均质量分 82
RJ28
小学生
展开
-
BSUIR Open 2017 Finals Financial Reports(线段树)
题意:10^5的数列,让你交换两个数,使得交换后的数列的连续区间最大和最大。分析:我们假设最优解是交换u 和 v,u >= v,那么交换后的最优解应该是以交换后u向左右两端分别扩展的一段区间,和u之前位置异侧的最大扩展值可以O(n)的DP预处理出来,然后我们考虑和u之前位置(也就是v现在的位置)同侧的最大扩展区间,可以证明在原数列中u一定是这个扩展区间终点再往后/前的最大值,所以我们考原创 2017-09-23 00:34:13 · 388 阅读 · 0 评论 -
Hdu-5893 List wants to travel(树链剖分)
Problem DescriptionA boy named List who is perfect in English. Now he wants to travel and he is making a plan. But the cost of living in same citie always changes. Now he wants to know how many diff原创 2016-09-18 23:11:53 · 398 阅读 · 0 评论 -
AIM Tech Round 3 (Div. 1) B. Recover the String(构造)
B. Recover the Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor each string s consisting of characters '0' a原创 2016-09-05 16:19:21 · 375 阅读 · 0 评论 -
Spoj - 1825 Free tour II(树的点分治)
题意:给一棵树,m个黑点和一个K,问最长的不超过k个黑点的带权路径。分析:树上的点分治,被卡了一天,因为宏定义出现了神奇的错误。#include#include#include#include#include#include#include#include#include#include#include#define INF 0x3f3f3f3f#d原创 2016-09-16 23:42:27 · 360 阅读 · 0 评论 -
UVALive 7155 Keyboarding(BFS)
题意:给定一个r*c的键盘,键盘由字母和数字还有一些符号的按键组成,键盘光标的起始位置在左上角,每次移动可以朝上下左右四个方向跳到一个和当前位置字符不同的按键处,给定一串长字符,问至少要按多少次键盘。分析:直接BFS,f[i][j][k]表示当前在(i,j)位置,已经按了k个键的最小值。#include#include#include#include#include原创 2016-09-03 19:03:40 · 508 阅读 · 0 评论 -
Ural 2037. Richness of binary words (打表+构造)
DescriptionFor each integer i from 1 to n, you must print a string si of length n consisting of letters ‘a’ and ‘b’ only. The string si must contain exactly i distinct palindrome substrings. Two sub原创 2016-08-08 14:02:24 · 392 阅读 · 0 评论 -
LA 3514 The Ministers' Major Mess(2-SAT)
题意: n 个人对m个方案投票 。 每个人最多对4个方案投票, 问是否存在一种决定 , 使每个人都有超过一半的建议被采用 。 且哪些方案的态度是确定的。分析:投票数#include#include#include#include#include#include#include#include#include#include#include#inc原创 2016-08-07 02:36:21 · 602 阅读 · 0 评论 -
Hdu-3709 Balanced Number(数位DP)
DescriptionA balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. W原创 2016-08-17 22:24:03 · 286 阅读 · 0 评论 -
UVALive 7416 Bringing Order to Disorder(搜索)
题意:给你一个n位”数“(前导0也算数字),问小于它的数字有多少,其中小于号重载为:1.a各个位上的数字和小于b.2.1相等的前提下a各个位上的数字+1相乘小于b.3.1,2相等的前提下a的十进制意义小于b。分析:原创 2016-08-28 00:27:50 · 603 阅读 · 0 评论 -
Hdu-5845 Best Division (trie+DP)
Problem DescriptionYou are given an array A, consisting of N integers.You are also given 2 integers K and L.You must divide the whole array A into exactly K nonempty intervals, such that the原创 2016-08-16 18:03:57 · 853 阅读 · 2 评论 -
Codeforces Round #363 (Div. 2) D. Fix a Tree (并查集)
A tree is an undirected connected graph without cycles.Let's consider a rooted undirected tree with n vertices, numbered1 through n. There are many ways to represent such a tree. One way is to cre原创 2016-07-20 10:17:21 · 541 阅读 · 0 评论 -
Hdu-5884 Sort(k叉哈夫曼树)
Problem DescriptionRecently, Bob has just learnt a naive sorting algorithm: merge sort. Now, Bob receives a task from Alice.Alice will give Bob N sorted sequences, and the i-th sequence includ原创 2016-09-20 15:34:40 · 432 阅读 · 0 评论 -
UVALive-3683 A Scheduling Problem(treedp)
题意: 有n(nB表示A必须在B之前完成,A-B表示A和B不能在同一天晚上。输入保证约束图是将一颗树的一些边定向之后得到的。分析: 这题好神,我一开始根据题目的提示想了个错误的贪心,然后疯狂WA了一天。 我一开始错误的贪心是认为对于原图最长链k大于2的情况,答案为k+1当且仅当只有一个无向边定向后参与入了新的最长链的构造,于是我一开始的做法就是特判k = 2的情况原创 2016-11-29 10:30:37 · 774 阅读 · 1 评论 -
Ural 2041 Nanomatryoshkas(贪心)
Matryoshka is a traditional Russian recursive doll. But everything changes, and even matryoshka needs a little innovation.Due to the use of new materials, it became possible to make a matryoshka arbit原创 2016-08-12 16:39:52 · 380 阅读 · 0 评论 -
Hdu-6052 To my boyfriend(单调栈)
Dear Liao I never forget the moment I met with you. You carefully asked me: "I have a very difficult problem. Can you teach me?". I replied with a smile, "of course". You replied:"Given a matrix,原创 2017-07-28 00:44:54 · 1760 阅读 · 6 评论 -
Codeforces Round #411 (Div. 1) D. Expected diameter of a tree(树的直径)
Pasha is a good student and one of MoJaK's best friends. He always have a problem to think about. Today they had a talk about the following problem.We have a forest (acyclic undirected graph) with原创 2017-05-09 22:37:35 · 822 阅读 · 0 评论 -
Uva-11768 Lattice Point or Not(欧扩)
题意:给你一个线段,问线段上有多少个整点.分析:我们先把直线的一般式搞出来,ax+by=c的形式,然后用欧扩求出直线一个整数点,设其横标为x,那么答案就是floor((x2-x)/b') - ceil((x1-x)/b') + 1. (x2 >= x1, b' = b/gcd(a,b)).#include #define INF 1047483647#define ep原创 2017-04-19 22:18:02 · 602 阅读 · 0 评论 -
Codeforces Round #407 (Div. 1) B. Weird journey
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia.It is widely known that Uzhlyandia has n cities connected with m bidirectio原创 2017-04-02 23:23:17 · 518 阅读 · 0 评论 -
Codeforces Round #395 (Div. 1) E. Timofey and our friends animals(lct动态维护mst)
After his birthday party, Timofey went to his favorite tree alley in a park. He wants to feed there his favorite birds — crows.It's widely known that each tree is occupied by a single crow family.原创 2017-02-03 17:48:53 · 490 阅读 · 0 评论 -
Codeforces Round #259 (Div. 1) B. Little Pony and Harmony Chest(状压dp)
Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony.A sequence of positive integers bi is harmony if and only if for every two elements原创 2017-02-03 11:08:26 · 640 阅读 · 0 评论 -
Bzoj-2759: 一个动态树好题
Description有N个未知数x[1..n]和N个等式组成的同余方程组:x[i]=k[i]*x[p[i]]+b[i] mod 10007其中,k[i],b[i],x[i]∈[0,10007)∩Z你要应付Q个事务,每个是两种情况之一:一.询问当前x[a]的解A a无解输出-1x[a]有多解输出-2否则输出x[a]二.修改一个等式C a k[a] p原创 2016-12-28 20:16:58 · 584 阅读 · 0 评论 -
ICPCCamp 2017-Day1 E.Lowest Common Ancestor(树链剖分/lct)
题意:给一棵带权树,问每个点和所有标号小于它的点的带权lca和。分析:这种lca和可以看成是两段权值不同的链的差,这样我们用lct来维护树上每段链的带权重量和,每次插入一个点。#include#include#include#include#include#include#include#include#include#include#include#原创 2017-02-13 08:52:36 · 413 阅读 · 0 评论 -
Codeforces Beta Round #11 D. A Simple Task(状压DP)
Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or edges.InputThe first line of input contains two integers n and m (1 ≤ n ≤ 19,原创 2017-02-06 16:11:38 · 493 阅读 · 0 评论 -
Codeforces Round #380 Div. 1 C. Subordinates(贪心)
There are n workers in a company, each of them has a unique id from1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior.There was原创 2016-11-30 09:47:47 · 317 阅读 · 0 评论 -
UVa 11090 Going in Cycle!!(环上平均值最大+SPFA DFS判负环)
题意:给定一个n个点m条边的加权有向图,求平均权值最小的回路。分析:二分+负权回路的判断,数据居然有自环,MDZZ,WA了一晚上。#include #include #include #include #include #include #include #include #include #defi原创 2016-07-27 23:54:49 · 548 阅读 · 0 评论 -
Vijos-1243 生产产品 (DP单调队列优化)
描述在经过一段时间的经营后,dd_engi的OI商店不满足于从别的供货商那里购买产品放上货架,而要开始自己生产产品了!产品的生产需要M个步骤,每一个步骤都可以在N台机器中的任何一台完成,但生产的步骤必须严格按顺序执行。由于这N台机器的性能不同,它们完成每一个步骤的所需时间也不同。机器i完成第j个步骤的时间为T[i,j]。把半成品从一台机器上搬到另一台机器上也需要一定的时间K。同时,为了保证原创 2016-06-20 21:37:03 · 566 阅读 · 0 评论 -
Codeforces Round #349 (Div. 2) C. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have f原创 2016-04-30 22:21:11 · 1290 阅读 · 0 评论 -
Gym 100917 A. Abstract Picture
Famous abstract painter Va Sya plans to start new painting. It will be composed as square with gridn × n, where each unit square is painted by some color.Va Sya already defined the colors for some unit squares. Color of other squares does not matter for h原创 2016-03-27 15:24:47 · 709 阅读 · 0 评论 -
POJ-1942 Paths on a Grid
Time Limit: 1000MS Memory Limit: 30000KTotal Submissions: 24046 Accepted: 5947DescriptionImagine you are attending your math lesson at school. Once again, you are bored because原创 2016-04-15 21:48:25 · 401 阅读 · 0 评论 -
LA 4725 Airport
AirportA big city has an international airport handling 40 million passengers a year. But this is notorious as one of the most congested airports in the world. In this airport, there is only one lan原创 2016-04-28 19:45:02 · 971 阅读 · 0 评论 -
Codeforces 526C - Om Nom and Candies
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with原创 2016-05-10 19:37:14 · 1241 阅读 · 0 评论 -
POJ-1191 棋盘分割
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 13871 Accepted: 4932Description将一个8*8的棋盘进行如下分割:将原棋盘割下一块矩形棋盘并使剩下部分也是矩形,再将剩下的部分继续如此分割,这样割了(n-1)次后,连同最后剩下的矩形棋盘共有n块矩形棋原创 2016-04-14 11:58:05 · 355 阅读 · 0 评论 -
POJ-1845 Sumdiv
DescriptionConsider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).InputThe only line contains the原创 2016-04-26 21:57:42 · 703 阅读 · 0 评论 -
Educational Codeforces Round 3 C. Load Balancing
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the school computer room there are n servers which are responsible for原创 2016-03-26 09:37:06 · 466 阅读 · 0 评论 -
POJ-3276 Face The Right Way
Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 3740 Accepted: 1724DescriptionFarmer John has arranged his N (1 ≤ N ≤ 5,000) cows in a row and many of them are fa原创 2016-03-31 17:39:36 · 752 阅读 · 0 评论 -
Gym 100917 F - Find the Length
time limit per test4 seconds (5 seconds for Java)memory limit per test256 megabytesinputstandard inputoutputstandard outputFor each vertice of given undirected weighted graph c原创 2016-03-29 13:48:18 · 701 阅读 · 0 评论 -
LA 3266 Tian Ji -- The Horse Racing (贪心 || DP)
Problem DescriptionHere is a famous story in Chinese history."That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to play horse racing with the king原创 2016-04-30 23:18:06 · 496 阅读 · 0 评论 -
Codeforces Round #352 (Div. 1) A. Recycling Bottles
It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin.We can think Central Perk as coordi原创 2016-05-12 22:55:42 · 337 阅读 · 0 评论 -
POJ-2635 The Embarrassed Cryptographer
DescriptionThe young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of users, which is now in use in his company. The cryptographic原创 2016-04-18 22:06:12 · 351 阅读 · 0 评论 -
LA 3523 Knights of the Round Table(点双连通分量+二分图判断)
题意:有n个骑士经常举行圆桌会议,商讨大事,每次圆桌会议至少应有3个骑士参加,且互相憎恨的骑士不能坐在圆桌旁的相邻位置,如果发生意见分歧,则需要举手表决,因此参加会议的骑士数目必须是奇数,以防赞同和反对票一样多,知道哪些骑士互相憎恨之后,你的任务是统计有多少个骑士不可能参加任何一个会议。分析:求出原图的补图后,问题转化为判断一个点是否存在一个奇数环内,一个环内的所有点一定在同一个点双联原创 2016-07-24 15:37:56 · 422 阅读 · 0 评论