Codeforces Round #375 (Div. 2) - A】的更多相关文章

题目链接:http://codeforces.com/contest/723/problem/D 题意:给定n*m小大的字符矩阵.'*'表示陆地,'.'表示水域.然后湖的定义是:如果水域完全被陆地包围则称为湖. 海的定义:如果水域与任何一个边界的水域有连通则陈伟海.现在要求填一些湖使得最后湖的数量恰好等于K.输出最小要填多少个单位的'.'水域和最终填完之后的字符矩阵. 思路:水题.注意本题的连通是四个方向[上下左右],然后dfs每一个连通块,对于每个连通块我们维护2个值:水域的数目和连通块属于海…
题目链接:http://codeforces.com/contest/723/problem/C 题意:给定长度为n的一个序列.还有一个m.现在可以改变序列的一些数.使得序列里面数字[1,m]出现次数最小的次数尽可能大.输出出现次数最小的次数.需要改变序列多少次.改变后的序列. 思路:题意有点难懂.可以发现出现次数最小的次数最大一定是(n/m).所以枚举数字[1,m]如果数字i(1<=i<=m)出现次数小于n/m,则要把序列某个数替换成i,怎么选择用哪些数来替换.应该选序列值大于m的或者序列值…
题目链接:http://codeforces.com/contest/723/problem/B 题意:给定一个字符串.只包含_,大小写字母,左右括号(保证不会出现括号里面套括号的情况),_分隔开单词.现在要你输出括号外面的单词的最大长度和括号里面出现的单词数目 思路:按照题目模拟就好了.写的比较搓. #define _CRT_SECURE_NO_DEPRECATE #include<stdio.h> #include<string.h> #include<cstring&g…
题目链接:http://codeforces.com/contest/723/problem/A 题意:在一维坐标下有3个人(坐标点).他们想选一个点使得他们3个到这个点的距离之和最小. 思路:水题.显然对这3个坐标点排序.则选的点一定是中间那个点最优. #define _CRT_SECURE_NO_DEPRECATE #include<stdio.h> #include<string.h> #include<cstring> #include<algorithm…
F. st-Spanning Tree 题目连接: http://codeforces.com/contest/723/problem/F Description You are given an undirected connected graph consisting of n vertices and m edges. There are no loops and no multiple edges in the graph. You are also given two distinct…
E. One-Way Reform 题目连接: http://codeforces.com/contest/723/problem/E Description There are n cities and m two-way roads in Berland, each road connects two cities. It is known that there is no more than one road connecting each pair of cities, and ther…
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…
B. Text Document Analysis 题目连接: http://codeforces.com/contest/723/problem/B Description Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of cha…
A. The New Year: Meeting Friends 题目连接: http://codeforces.com/contest/723/problem/A Description There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the point x2, and the…
http://codeforces.com/contest/723/problem/C 题目是给出一个序列 a[i]表示第i个歌曲是第a[i]个人演唱,现在选出前m个人,记b[j]表示第j个人演唱歌曲的数量, 现在你可以改变a[]这个数组,使得前m个人的演唱歌曲的数量的最小值最大. 很明显对于前m个人,每个人唱了多少首是很容易统计出来的,只需要对<=m的人进行统计即可,不用统计>m的,这样的话数组只需开到2000即可. 对于后面的人,可以改变,优先改变前m个人中演唱歌曲最小的那个,这个可以用优…
http://codeforces.com/contest/723/problem/D 这题是只能把小河填了,题目那里有写,其实如果读懂题这题是挺简单的,预处理出每一块的大小,排好序,从小到大填就行了. 以前找这些块的个数用的是dfs.现在这次用并查集做下. 首先要解决的是,二维坐标怎么并查集,以前的并查集都是一维的,现在是两个参数,那么就考虑离散,每对应一个点,离散到一个独特的一维数值即可.我用的公式的50 * x + y.这样得到的数值是唯一的.所以可以快乐地并查集了. 那么遇到一个'.',…
A. The New Year: Meeting Friends 水 #include <set> #include <map> #include <stack> #include <queue> #include <cstdio> #include <vector> #include <cstring> #include <iostream> #include <algorithm> using…
传送门 分析:构造题.可以这么想:先把s,t两个点去掉,把剩下的点先并查集合并.这样会出现个集合:, , 个剩余集合.那么个集合中先把只能与或中一个相连的连起来,如果这样已经超出了要求,那么就不能构造.剩余的既能和又能和相连的集合就按照不超过,这两个要求相连,可以则,否则为.这样有一个特殊情况:就是或者可能只有一条边连向和,不知道有没有说清楚,就是对于只有或者对于只有.这个需要在最后进行特判. 代码: /**********************************************…
A 数轴上有三个人要到一个点去过年 使三个人走路距离的和最小  让两边的人都走到中间那个点即可 B 给出一个字符串 其中有_ ( ) 三种字符和英文字母 连续的英文字母是一个单词 括号对中不会套括号对 求 括号外最长的单词长度 括号内有多少单词 维护一个bool变量表示当前单词在不在括号内 res表示当前单词的长度 可见 _() 都是分隔符 C 给出一个节目表 其中有n个曲目 每一个ai 代表这个曲目由ai乐队演奏 但是某人只喜欢标号是1-m的乐队 现在他可以对每个节目的乐队进行更换 问 最少更…
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…
C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a…
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…
A. The New Year: Meeting Friends time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, t…
A - The New Year: Meeting Friends 水 #include<iostream> #include<algorithm> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; cout<<max(a,max(b,c)) - min(a,min(b,c)) <<endl; ; } B - Text Document Analysis…
A. The New Year: Meeting Friends time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, t…
题目链接:传送门 题目大意:一副无向图,要求你给边定向(变为有向图),使出度等于入度的点最多,输出有多少 个点,并且输出定向后的边(前为起点,后为终点) 题目思路:欧拉路 我们这样考虑,先考虑无向图的点的度数,如果为奇数则一定无法变为题目要求的点,ans-1 对于度为偶数的点则一定可以通过调整满足. 处理方法:新建一个虚拟节点0,使所有度为奇数的点向其连一条边,那么最终图中的点的度数都为偶数. 这样就满足欧拉路的条件了.我们只需要跑欧拉路并且将走过的路径保留下来即可. 注意将与虚拟节点连的边删去…
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…
PS_B:阿洗吧!B题卧槽数组开了250... PS_D:D题主要挂在了50*50口算得了250,数组开小,然后一开始还错了.= =哎,以后对于数据范围还是注意一点: 卧槽,这场可真二百五了... A题: 水~ #include<cstdio> #include<iostream> #include<string.h> #include<algorithm> using namespace std; const int N=1010; int sum; in…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…