题目简单,不多解释. Code: #include<cstdio> #include<queue> using namespace std; const int maxn = 1000000 + 3; int head[maxn], to[maxn], nex[maxn], cnt, dep[maxn], numv[maxn]; queue<int>Q; inline void add_edge(int u,int v) { nex[++cnt] = head[u],…
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any othe…
A. Friends Meeting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x1 = a, another…
The last stage of Football World Cup is played using the play-off system. There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the…
D:首先考虑如果给定白棋位置,如何判断胜负.黑棋获胜需要四个方向都有能贴上白棋的棋子.由于每一轮都必须移动,显然先对平面黑白染色一下,只有与白棋所在格异色的黑棋才需要考虑.考虑让一个黑棋去贴上白棋某个方向,那么能贴上的条件是该方向坐标之差>另一方向坐标之差.因为如果其往这边逃的话,这样才有足够的时间冲过去拦住.若往其他方向逃,只要模仿其动作即可,处于逃跑方向的棋子会对其作出制裁. 可以发现每个黑棋对每个位置的白棋都只有一种能将其锁死的方向,四个方向的分界线形成一个X形.于是现在要数的是被任意四个…
A.B都是暴力搞一搞. A: #include<bits/stdc++.h> #define fi first #define se second #define mk make_pair #define pii pair<int,int> #define read(x) scanf("%d",&x) #define sread(x) scanf("%s",x) #define dread(x) scanf("%lf&quo…
题意:一个串,右循环移位后,告诉你第一个字母,还能告诉你一个,问你能确定移位后的串的概率. 用map记录每个字母出现的位置.对于每个字母,用arr[j][k]记录它的所有出现位置的后j位是字母k的个数.对每个j数arr[j]中arr[j][k]等于1的个数,取最大,说明k取这个时区分该字母的概率最大.统计所有字母的该值除以字符串长度即为结果. //#pragma comment(linker,"/STACK:1024000000,1024000000") #include<ios…
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error. Kirill has already made his measurements, and has got the following integer value…
Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x1 = a, another one is in the point x2 = b. Each of the friends can move by one along the line in any direction unlimited number of times. When…
今天老师(orz sansirowaltz)让我们做了很久之前的一场Codeforces Round #257 (Div. 1),这里给出A~C的题解,对应DIV2的C~E. A.Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has a big rectangular cho…