codeforces 357】的更多相关文章

C 题意: ###n个勇士编号1-n,m个回合对战,每个回合由仍留在游戏里的编号Li~Ri的人参加,胜者为Xi,输的人退出游戏. ###求一个a1-an的序列,若ai为胜者,则ai=0,否则ai=打败ai的勇士的编号. 思路: 解法一:使用set,输的人擦除. #include<bits/stdc++.h> using namespace std; set<int> s; set<int>::iterator it,lp; ]={},del[]; int main()…
E. Runaway to a Shadow 题目连接: http://www.codeforces.com/contest/681/problem/E Description Dima is living in a dormitory, as well as some cockroaches. At the moment 0 Dima saw a cockroach running on a table and decided to kill it. Dima needs exactly T…
D. Gifts by the List 题目连接: http://www.codeforces.com/contest/681/problem/D Description Sasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are n men in Sasha's fam…
C. Heap Operations 题目连接: http://www.codeforces.com/contest/681/problem/C Description Petya has recently learned data structure named "Binary heap". The heap he is now operating with allows the following operations: put the given number into the…
B. Economy Game 题目连接: http://www.codeforces.com/contest/681/problem/B Description Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, th…
A. A Good Contest 题目连接: http://www.codeforces.com/contest/681/problem/A Description Codeforces user' handle color depends on his rating - it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or…
A. A Good Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if…
传说中做cf不补题等于没做 于是第一次补...这次的cf没有做出来DE D题的描述神奇 到现在也没有看懂 于是只补了E 每次div2都是hack前2~3题 终于打出一次hack后的三题了...希望以后能越来越好 早日..至少变成蓝色名字吧:) E题意 有一个蟑螂 人要打死它 给出蟑螂的坐标 速度 人的瞄准时间 再给出一些阴影(圆形且给出坐标与半径) 若蟑螂移动到阴影内会立即停下 人不能打到阴影中的蟑螂 问它不被打死的机率 蟑螂的移动方向是随机的 需要注意的是蟑螂只会朝一个方向走直线 所以我们对于…
C. Heap Operations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya has recently learned data structure named "Binary heap". The heap he is now operating with allows the following…
C. Heap Operations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya has recently learned data structure named "Binary heap". The heap he is now operating with allows the following…
B. Economy Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he…
用单调队列(从小到大),模拟一下就好了,主要是getMin比较麻烦,算了,都是模拟....也没什么好说的.. #include<cstdio> #include<map> #include<queue> #include<iostream> #include<stdlib.h> #include<string.h> #include<algorithm> using namespace std; priority_queu…
题目链接:http://codeforces.com/problemset/problem/357/B 题目意思:输入n个人和m场舞蹈,给出每场舞蹈(只有3个人参与)中参与的舞者的编号,你需要为这些舞者安排衣服的颜色,使得每场舞蹈中3个舞者的颜色都满足是白,红,绿的条件. 特别要注意题目中的两句话:if some dance has two or more dancers from a previous dance, then the current dance stops being spec…
题目链接:http://codeforces.com/problemset/problem/357/A 题目意思:将一堆人分成两组:beginners 和 intermediate coders .每一个人都有一个point,给出每一个point里的总人数(Ci 个人有分数 i )和 x,y,需要找出划分为两组后,每一个组的人数(假设为a,b)符合 x <=  a  <= y 并且 x<= b <= y 的条件,输出这a个人是小于哪个point的,这个point还应该满足另一组的b…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连通图)且这颗树中必须包含节点1 然后将这颗子树中的所有点的点权+1或-1 求把所有点权全部变为0的最小次数(n<=10^5) 题解: 因为每一次的子树中都必须有1,所以我们得知每一次变换的话1的权值都会变化 所以我们以1为根 现在,我们发现,如果一个节点的权值发生变化,那么他的父节点的权值一定发生变…
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a3-+ai,问满足Si<=p的i的最大值的期望.(p<=50) (大意来自于http://www.cnblogs.com/liu-runda/p/6253569.html) 我们知道,全排列其实等价于我们一个一个地等概率地向一个序列里面插入数值 所以我们可以这么看这道题: 现在有n个数,有n个盒子…
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不同的点的数量+1) 每一次只有当子树中所有的点都已经游走过了再会向父亲走,走到每个儿子上的概率是相同的 对于每个点,求他的权的期望 (1 ≤ n ≤ 10^5) 题解: 首先我们发现,所有子树中所有的点的编号都一定比父亲要大 而且子树中的大小关系和我们访问它的顺序有关 如果对于一个节点u它的儿子为v…
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次抓一只老鼠,龙每次抓完一只老鼠之后会有一只老鼠跑出来. 每次抓老鼠和跑出来的老鼠都是随机的. 如果两个人都没有抓到白色老鼠则龙赢.王妃先抓. 问王妃赢的概率. (0 ≤ w, b ≤ 1000). 题解: 其中第一行表示为王妃拿到的白色老鼠,自然是直接退出了 第二行表示为王妃拿到了黑色老鼠,但是因为…
http://codeforces.com/problemset/problem/453/A 题目大意: 给定一个m面的筛子,求掷n次后,得到的最大的点数的期望 题解 设f[i]表示掷出 <= i 的点数的概率 ans = sigma{i*(f[i]-f[i-1])} 单个f[i]直接快速幂计算 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typede…
http://codeforces.com/problemset/problem/749/E (题目链接) 题意 给出一个1~n的排列,从中等概率的选取一个连续段,设其长度为l.对连续段重新进行等概率的全排列,求排列后整个原序列的逆序对的期望个数. Solution 考虑对于每一对数${(a_i,a_j),i<j}$算贡献. 1.连续段包含${a_i,a_j}$ 不妨设${a_i<a_j}$,则只有当排列后${a_j}$再${a_i}$前面才会对答案有贡献(${a_i>a_j}$的情况同…
http://codeforces.com/problemset/problem/696/B (题目链接) 题意 给出一棵树,随机dfs遍历这棵树,求解每个节点的期望dfs序. Solution 考虑对于节点u,其某个儿子节点v的期望是多少. 首先,节点u的儿子的dfs的顺序是其儿子数son[x]的全排列.考虑在排列中有多少个节点在v的前面,不妨设x排在v的前面,那么满足的排列数为:${P_n^{n-2}}$,于是x对v的期望的贡献为:$${\frac{P_n^{n-2}×size[x]} {P…
http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的概率最大. Solution 很显然的概率dp,过了样例即可AC..话说我为什么要刷B题→_→ 代码 // codeforces442B #include<algorithm> #include<iostream> #include<cstdlib> #include<…
http://codeforces.com/problemset/problem/148/D (题目链接) 题意 包中有w个白鼠,b个黑鼠.公主和龙轮流画老鼠,公主先画,谁先画到白鼠谁就赢.龙每画完一只老鼠,就会有另一只老鼠从包中跑出来.每只老鼠被画到以及跑出的概率相等,问公主获胜的概率. Solution 令${f_{0/1,i,j}}$表示此时公主/龙选,包中还剩i只白鼠,j只黑鼠,公主赢的概率.那么转移很显然: $${f_{0,i,j}=\frac{i}{i+j}+\frac{j}{i+j…
吐槽一句:这数据造得真强-. 题意:有一个大小为k的缓存区,每次从n种物品中按照一定的概率选取一种物品尝试放进去.同一个物品每一次选取的概率都是相同的.如果这种物品已经放进去过就不再放进去.如果缓存区满了就把放进去的时间离现在最远的物品拿出来.问10^100次后每个物品在缓冲区中的概率. 如果正着做的话似乎状态会扩展得很多而且都没什么用. 注意到最后一次放进去的一个物品肯定在缓冲区中,而第一次放进去的物品对结果几乎没有影响,这提示我们关注最后的几次放置.假如缓冲区至少有两个位置,且倒数第二个物品…
题意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a3-+ai,问满足Si<=p的i的最大值的期望.(p<=50) 这道题在网上有一些不同的做法,O(n^3)或O(n^4)都可以通过,这里整合一下,标上出处,其实我只写了自己YY的那一种,叫我搬运工 1.期望的线性性,讨论每个数对i的贡献.O(n^4) 自己YY的,不知道以前有没有人也写过这种方法. 如果ai满足Si<=p,那么ai就对答案有1 的贡献,因此我们算出每个数ai满足Si<…