
codeforces
u010660276
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #276 (Div. 2)(C贪心,D)
C. Bitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's denote as the number of bits set ('1' bits) in the bina原创 2014-11-08 09:58:41 · 644 阅读 · 0 评论 -
Bayan 2015 Contest Warm Up(C,D)
B. Strongly Connected CityImagine a city with n horizontal streets crossingm vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city h原创 2014-10-11 13:35:05 · 534 阅读 · 0 评论 -
线段树(good)Codeforces Round #275 (Div. 2)D
题意: 构造一个序列,满足m个形如:[l,r,c] 的条件。 [l,r,c]表示[l,r]中的元素按位与(&)的和为c。解法: 线段树维护,sum[rt]表示要满足到现在为止的条件时该子树的按位与和至少为多少。更新时,如果val的pos位为1,那么整个区间的按位与和pos位也应该为1,否则与出来就不对了。(这是本题解题的核心)那么此时更新 sum[rt] |= val 即可。然后再ch原创 2014-10-29 17:56:03 · 536 阅读 · 0 评论 -
Codeforces Round #275 (Div. 2)B
B. Friends and Presentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have two friends. You want to present each原创 2014-10-28 19:34:59 · 403 阅读 · 0 评论 -
Codeforces Round #266 (Div. 2)(good)
B. Wonder RoomThe start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has aa × b square meter wonder room. The careta原创 2014-10-03 20:37:25 · 917 阅读 · 0 评论 -
Codeforces Round #283 (Div. 2)D(good)
D. Tennis Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya and Gena love playing table tennis. A single mat原创 2014-12-23 23:05:47 · 477 阅读 · 0 评论 -
Codeforces Round #289 (Div. 2, ACM ICPC Rules)C、E
E. Pretty SongWhen Sasha was studying in the seventh grade, he started listening to music a lot. In order to evaluate which songs he likes more, he introduced the notion of the song's原创 2015-02-02 17:40:54 · 499 阅读 · 0 评论 -
Codeforces Round #279 (Div. 2)(good)
隔了好久才补上这场,感觉这场总体还不错C. Hacking Cyphertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus participates in原创 2014-12-28 21:31:42 · 419 阅读 · 0 评论 -
Codeforces Round #280 (Div. 2)E good
E. Vanya and Fieldtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVanya decided to walk in the field of size n × n c原创 2014-12-30 13:49:02 · 429 阅读 · 0 评论 -
Codeforces Round #264 (Div. 2)(好)
C. Gargari and Bishopstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGargari is jealous that his friend Caisa won t原创 2014-09-03 14:28:42 · 497 阅读 · 0 评论 -
Codeforces Round #261 (Div. 2)(树状数组,dp,dfs构造序列)
C. Pashmak and BusesRecently Pashmak has been employed in a transportation company. The company hask buses and has a contract with a school which hasn students. The school planned to take原创 2014-08-17 10:13:04 · 846 阅读 · 0 评论 -
Codeforces Round #246 (Div. 2)
C. Prime SwapsYou have an array a[1], a[2], ..., a[n], containing distinct integers from1 to n. Your task is to sort this array in increasing order with the following operation (you may need t原创 2014-06-20 17:34:36 · 532 阅读 · 0 评论 -
Codeforces Round #241 (Div. 2)
A - Guess a number!原创 2014-04-13 22:37:07 · 468 阅读 · 0 评论 -
Codeforces Round #242 (Div. 2)
A - Squats #include#includeusing namespace std;int main(){ int n; string a; cin>>n>>a; int len=a.size(); int d=0,u=0; for(int i=0;i<len;i++)if(a[i]=='x')d++;else u++;原创 2014-04-25 23:00:37 · 515 阅读 · 0 评论 -
Codeforces Round #250 (Div. 2)(B,C,D并查集)
比赛的时候没想明白。。。原创 2014-06-03 22:48:39 · 628 阅读 · 0 评论 -
Codeforces Round #245 (Div. 2)
A. Points and Segments (easy)题意:给定的区间内0,1的个数之差不能超过一思路:原创 2014-05-27 16:45:18 · 523 阅读 · 0 评论 -
Codeforces Round #249 (Div. 2)
A. Queue on Bus StopIt's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their o原创 2014-06-18 16:36:44 · 699 阅读 · 0 评论 -
Codeforces Round #259 (Div. 2)C
C. Little Pony and Expected Maximumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwilight Sparkle was playing Ludo原创 2014-08-04 10:44:34 · 555 阅读 · 0 评论 -
扩展KMP模板
#includeusing namespace std;const int N = 101010;int next[N],extand[N];void getnext(char *T) // next[i]: 以第i位置开始的子串 与 T的公共前缀{ int n=strlen(T); next[0]=n; int j=0; while(j+1<n&&T[j原创 2014-06-16 14:10:56 · 542 阅读 · 0 评论 -
Codeforces Round #251 (Div. 2)
D. Devu and his Brothertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDevu and his brother love each other a lot. As原创 2014-06-21 15:51:56 · 507 阅读 · 0 评论 -
Codeforces Round #FF (Div.2 )(C,D)
C. DZY Loves SequencesDZY has a sequence a, consisting of n integers.We'll call a sequence ai, ai + 1, ..., aj(1 ≤ i ≤ j ≤ n) a subsegment of the sequencea. The value (j - i + 1) denot原创 2014-07-14 11:13:09 · 576 阅读 · 0 评论 -
Good Bye 2014(codeforces)
这次倒序写题解。D. New Year Santa NetworkNew Year is coming in Tree World! In this world, as the name implies, there aren cities connected by n - 1 roads, and for any two distinct citi原创 2014-12-31 11:09:01 · 580 阅读 · 0 评论 -
Rockethon 2015C
题意:给定n个区间(n<=5)[l,r],从没个区间任选一个数,问第二大的数的期望是多少 思路:此题主要是避免重复计算 从[1,104]枚举第二高价,EXP=$$\sum_{i=1}^{10^4} Pi*i,用此公式求得期望。 Pi=EachiTotal,Eachi表示每一个第二高价的情况数 Total=∏Ni=1(Ri−Li 1),Total表示总情况数 期望还可表示为:E转载 2015-02-09 21:07:15 · 440 阅读 · 0 评论 -
Codeforces Round #313 (Div. 2)D. Equivalent Strings(字符串)
D. Equivalent StringsToday on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:They are e原创 2015-07-25 11:36:23 · 483 阅读 · 0 评论 -
Codeforces Round #313 (Div. 2)E. Gerald and Giant Chess(Lucas定理+dp)
E. Gerald and Giant ChessGiant chess is quite common in Geraldion. We will not delve into the rules of the game, we’ll just say that the game takes place on an h × w field, and it is painted in two col原创 2015-07-25 16:12:28 · 697 阅读 · 0 评论 -
Codeforces Round #310 (Div. 1)B,C,D(set+线段树)
B. Case of FugitiveAndrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water.The only dry land there is an a原创 2015-07-04 11:19:04 · 1093 阅读 · 0 评论 -
Codeforces Round #311 (Div. 2)判环+Trie 好
C. Arthur and TableArthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable.In total the table Arthur bought has n legs, the length of原创 2015-07-05 11:12:38 · 443 阅读 · 0 评论 -
Codeforces Round #Pi (Div. 2)(最短路重建图+tarjan重边找桥)
C. Geometric ProgressionPolycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequen原创 2015-08-08 11:28:14 · 480 阅读 · 0 评论 -
Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1)A,B
A. Bear and PokerLimak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the原创 2015-08-31 14:02:54 · 436 阅读 · 0 评论 -
Codeforces Round #Pi (Div. 2)(最短路重建图+tarjan重边找桥)
C. Geometric ProgressionPolycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequen原创 2015-08-08 11:27:03 · 546 阅读 · 0 评论 -
Codeforces Round #343 (Div. 2)C. Famil Door and Brackets DP
转自:Codeforces Round #343 (Div. 2) 解题报告 题意:给你一个由括号组成的字符串,长度为m,现在希望获得一个长度为n(全由括号组成)的字符串,0<=n-m<=2000这个长度为n的字符串要求有两个性质:就是任意前缀,左括号数量大于右括号数量字符串中左括号的数量等于右括号现在让你可以在长度为m的原串前加一个括号串p,在原串后加一个括号串q 最后p+m+q=n问有多原创 2016-02-27 11:13:10 · 412 阅读 · 0 评论 -
Codeforces Round #368 (Div. 2)
C - Pythagorean Triples 题意:如何构造勾股数 设 (a,b,c) 是勾股数,当 a 为大于 1 的奇数 2n+1 时, b=2n2+2n,c=2n2+2n+1 ,当 a为大于 4 的偶数 2n 时, b=n2−1,c=n2+1 。D - Persistent Bookcase 将状态作为节点进行dfs,这样对于操作4就可以很方便的进行统计,详细见:Codeforce原创 2016-08-29 15:21:13 · 477 阅读 · 0 评论 -
Codeforces Round #306 (Div. 2)
C:给一个100位的数,问能不能删除一些,使得能被8整除如果后三位能被8整除,则可以被8整除#includeusing namespace std;char str[110];int main(){ while(scanf("%s",str)!=EOF) { int len=strlen(str); int i,j,k,flag=0;原创 2015-06-07 22:15:58 · 500 阅读 · 0 评论 -
Codeforces Round #308 (Div. 2)
C. Vanya and ScalesVanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams wherew is some integer not less than 2 (exactly one weight of each nominal valu原创 2015-06-20 18:36:23 · 592 阅读 · 0 评论 -
Codeforces Round #305 (Div. 1)B - Mike and Feet 线段树
B. Mike and Feettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMike is the president of country What-The-Fatherland.原创 2015-05-27 13:51:16 · 935 阅读 · 0 评论 -
Codeforces Round #292 (Div. 2)C,D拓扑排序
C. Drazil and FactorialDrazil is playing a math game with Varda.Let's define for positive integerx as a product of factorials of its digits. For example,.First, they choose a decimal原创 2015-02-25 16:51:58 · 483 阅读 · 0 评论 -
dp(Codeforces Round #293 (Div. 2)D. Ilya and Escalator)
D. Ilya and Escalatortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya got tired of sports programming, left univ原创 2015-02-26 15:41:09 · 524 阅读 · 0 评论 -
Codeforces Mr. Kitayuta's Technology
题意:给定有向图,问是的图连同的最小数量的边是多少思路:把有向图转换成无向图,dfs染色,处理出若干个无向图联通块。我们再考察每个无向图联通块中的有向边,如果他们构成了一个有向无环图(DAG),那么说明图中的点是可以拓扑排序的。那么使用点数减一条有向边就能构造出这个拓扑关系(按拓扑序连成一条链)。如果不是一个DAG,那么无法拓扑排序。那我可以将所有点连成一个环,这样任意两点之间都是可达的,需要原创 2015-01-24 22:14:41 · 636 阅读 · 0 评论 -
hash(Codeforces Round #294 (Div. 2)D. A and B and Interesting Substrings)
D. A and B and Interesting Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA and B are preparing themselve原创 2015-03-01 17:37:02 · 539 阅读 · 0 评论 -
中途相与法(Codeforces Round #297 (Div. 2)E - Anya and Cubes )
E. Anya and Cubestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnya loves to fold and stick. Today she decided to原创 2015-03-27 16:03:46 · 580 阅读 · 0 评论