Codeforces 1296F Berland Beauty】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/1296/F 思路: 1————2————3————4————5————6 1->3 2 2->4 3 3->5 3 4->6 5 题目说 (u->v w)途中所有边 e1,e2,e3,...en∈E,满足任意|ex| >= w(ex∈E), 上面图中  3->5 3    4->6 5,说明(|e(4->5)| >= 3 && |e(4-…
[Codeforces 1005F]Berland and the Shortest Paths(最短路树+dfs) 题面 题意:给你一个无向图,1为起点,求生成树让起点到其他个点的距离最小,距离最小的生成树可能有多个.给定k,如果方案数比k小就输出全部方案,否则输出k种方案. 分析 先跑最短路,对于每个点找到它在最短路树上可能的父亲.即对于\((x,y) \in E,dist(y)=dist(x)+len(x,y)\).那么y在最短路上可能的父亲就是x.说"可能"是因为最短路树可能不…
题意: 给一棵树,边权未知,现在给m组约束,每组约束给出从u到v路径中的最小值,现在让你给出一组边权,使得符合之前的约束,不能给出输出-1 思路: 因为n较小,对于每组约束我们可以直接暴力修改路径上的权值,如果边的权值小于当前约束的最小值,则将权值修改,最后再根据每组约束暴力走一遍路径看路径是否满足要求,如果不满足则输出-1,最后还得对那些没有修改过的边随意赋值 #include<iostream> #include<algorithm> #include<vector>…
Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room. Today was the pilot launch of an automated…
B. Berland National Library time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Berland National Library has recently been built in the capital of Berland. In addition, in the library you can t…
1C - Ancient Berland Circus 思路: 求出三角形外接圆: 然后找出三角形三条边在小数意义下的最大公约数; 然后n=pi*2/fgcd; 求出面积即可: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define INF (1e9…
XXI Berland Annual Fair is coming really soon! Traditionally fair consists of nnbooths, arranged in a circle. The booths are numbered 11 through nn clockwise with nnbeing adjacent to 11. The ii-th booths sells some candies for the price of aiai burle…
这类题一个操作增加多少,一个操作减少多少,求最少刚开始为多少,在中途不会出现负值,模拟一遍,用一个数记下最大的即可 #include<cstdio> #include<cstring> ; ],head[HASH],next[]; void insert(int s) { int h=num[s]%HASH; int u=head[h]; while(u) u=next[u]; next[s]=head[h];//原来的链表头成为s的next head[h]=s;//s成为head…
传送门 首先可以注意到序列里面元素的顺序对答案是没有影响的,所以二话不说先排序再看看怎么搞 考虑枚举每种子序列可能产生的贡献并算一下产生这个贡献的子序列有多少 考虑设 $F(x)$ 表示选择的元素差值至少为 $x$ 的长度为 $k$ 的子序列的方案数 那么最终如果直接把每个 $F(x),x \in [1,max(a)]$ 加起来会发现,对于任意一种差值为 $t$ 的方案,它都被所有 $x<=t$ 的 $F(x)$ 各计算到了一次,那么总贡献即为 $t$,所以只要求出 $F$ 然后加起来就是我们要…
A. Array with Odd Sum Description You are given an array \(a\) consisting of \(n\) integers. In one move, you can choose two indices \(1 \le i, j \le n\) such that \(i \ne j\) and set \(a_i := a_j\). You can perform such moves any number of times (po…
A - A CodeForces - 1042A There are nn benches in the Berland Central park. It is known that aiai people are currently sitting on the ii-th bench. Another mm people are coming to the park and each of them is going to have a seat on some bench out of n…
第一次就去拉了点思维很神奇的CF题目 2018省赛赛第一次训练 # Origin Title     A CodeForces 607A Chain Reaction     B CodeForces 385C Bear and Prime Numbers     C CodeForces 670D2 Magic Powder - 2     D CodeForces 360B Levko and Array     E CodeForces 68B Energy exchange     F…
2021-10-14 P2577 [ZJOI2004]午餐 2021-10-13 CF815C Karen and Supermarket(小小紫题,可笑可笑) P6748 『MdOI R3』Fallen Lord(sort(a+1,a+1+n,greater<int>()); 真好用) P4161 [SCOI2009]游戏 P1707 刷题比赛 2021-10-12 CF1573A Countdown P2717 寒假作业 P7868 [COCI2015-2016#2] VUDU P1660…
B. Berland National LibraryTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/B Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/B Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any o…
http://codeforces.com/contest/962/problem/E E. Byteland, Berland and Disputed Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The cities of Byteland and Berland are located on the a…
D. Lakes in Berland 题目连接: http://codeforces.com/contest/723/problem/D Description The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. Lakes…
A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if…
C. Old Berland Language 题目连接: http://www.codeforces.com/contest/37/problem/C Description Berland scientists know that the Old Berland language had exactly n words. Those words had lengths of l1, l2, ..., ln letters. Every word consisted of two letter…
E. Berland Local Positioning System Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem/E Description In Berland a bus travels along the main street of the capital. The street begins from the main square and looks l…
H - Roads not only in Berland Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 25D Description Berland Government decided to improve relations with neighboring countries. First of all, it…
codeforces 808G Anthem of Berland 题面 给定\(s\)串和\(t\)串,字符集是小写字母.\(s\)串中有些位置的值不确定,要求你确定这些位置上的值,使得\(t\)在\(s\)中出现次数最多,输出最多出现次数. 参考博客 http://www.cnblogs.com/Oncle-Ha/p/7061929.html 题解 AC自动机预处理 \(ne[i][j]\):字符串 \(t[i]+j\) 的后缀最长匹配到 \(t[ne[i][j]]\). 状态\(f[i][…
C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were s…
题目链接:http://codeforces.com/contest/440/problem/D D. Berland Federalization   Recently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is a…
题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况讨论一下 */ /************************************************ * Author :Running_Time * Created Time :2015-8-6 0:23:37 * File Name :B.cpp *****************…
F - Expected Square Beauty 思路:https://codeforces.com/blog/entry/68111 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1 y11 #define fi first #define se second #define…
海洋包围的小岛,岛内的有湖,'.'代表水,'*'代表陆地,给出的n*m的地图里至少有k个湖,求填掉面积尽量少的水,使得湖的数量正好为k. dfs找出所有水联通块,判断一下是否是湖(海水区非湖).将湖按面积排序,若湖的数量为cnt,填掉前cnt-k个湖. http://codeforces.com/problemset/problem/723/D Examples input 5 4 1*****..*******.*..** output 1*****..*********..** input…
Description The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of water cells, connected by sides, which are…
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or…