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

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…
Codeforces Round #261 (Div. 2)[ABCDE] ACM 题目地址:Codeforces Round #261 (Div. 2) A - Pashmak and Garden 题意:  一个正方形,它的边平行于坐标轴,给出这个正方形的两个点,求出另外两个点. 分析:  推断下是否平行X轴或平行Y轴,各种if. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * File: A.cpp * Create Date: 2014…
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…
题目链接: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…
原文链接http://www.cnblogs.com/zhouzhendong/p/8397685.html 2018-02-01 $A$ 题意概括 你要买$m$斤水果,现在有$n$个超市让你选择. 每个超市的水果价格是固定的.第$i$个超市的水果价格用两个整数$a_i和b_i$来表示.含义是$a_i$元可以买$b_i$斤. 问你买$m$斤水果最少花费多少钱. 题解 直接枚举超市,判断最少的花费就可以了. 代码 #include <cstring> #include <cstdio>…
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…
1136A: 题意:一本书有n个章节,每个章节的分别在li到ri页,小明读完书后将书折在第k页,问还有多少章节没有读 题解:控制k在li~ri的范围内后输出n-i即可 #include <set> #include <map> #include <deque> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <b…
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.这样得到的数值是唯一的.所以可以快乐地并查集了. 那么遇到一个'.',…
Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring Painting standard input/output 1 s, 256 MB    x2519 C Money Transfers standard input/output 1 s, 256 MB    x724 D Tree Construction standard input/outp…
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. Insomnia cure 哎 只能说英语太差,一眼题我看了三分钟. 题意:给5个数k, l, m, n 和 d,求1~d中能被k, l, m, n 至少一个整除的数的个数. 题解:…… 代码: #include <iostream> using namespace std; int main() { int a, b, c, d, n; cin >> a >> b >> c >> d >> n; ; ; i <= n;…
A. Two Substrings 题意:给一个字符串,求是否含有不重叠的子串"AB"和"BA",长度1e5. 题解:看起来很简单,但是一直错,各种考虑不周全,最后只能很蠢的暴力,把所有的AB和BA的位置求出来,能有一对AB和BA不重叠即可. #include <bits/stdc++.h> using namespace std; ]; vector<int> ab; vector<int> ba; int main() { w…
http://www.cnblogs.com/wenruo/p/5176375.html A. Wet Shark and Odd and Even 题意:输入n个数,选择其中任意个数,使和最大且为奇数. 题解:算出所有数的和,如果奇数的个数为奇数个,则减去最小的奇数,否则不用处理. #include <bits/stdc++.h> using namespace std; #define PI acos(-1.0) #define EXP exp(1.0) #define ESP 1E-6…
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,使所有度为奇数的点向其连一条边,那么最终图中的点的度数都为偶数. 这样就满足欧拉路的条件了.我们只需要跑欧拉路并且将走过的路径保留下来即可. 注意将与虚拟节点连的边删去…
A. Aramic script time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Aramic language words can only represent objects. Words in Aramic have special properties: A word is a root if it does no…