E. Three States Problem's Link Mean: 在一个N*M的方格内,有五种字符:'1','2','3','.','#'. 现在要你在'.'的地方修路,使得至少存在一个块'1','2'和'3'是连通的. 问:最少需要修多少个'.'的路. analyse: 想法题,想到了就很简单. 直接暴力枚举每个国家到每个可达的点的最小代价,然后计算总和取最小值. dis[k][x][y]表示第k个国家到达坐标(x,y)的点的最小代价. Time complexity: O(N) vi…
E. Three States Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem/E Description The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed…
题目链接: 题目 E. Three States time limit per test:5 seconds memory limit per test:512 megabytes 问题描述 The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed the residents of all…
C. Three States time limit per test 5 seconds memory limit per test 512 megabytes input standard input output standard output The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance an…
题目大意:有一个M*N的矩阵,在这个矩阵里面有三个王国,编号分别是123,想知道这三个王国连接起来最少需要再修多少路. 分析:首先求出来每个王国到所有能够到达点至少需要修建多少路,然后枚举所有点求出来最少的即可. 代码如下: --------------------------------------------------------------------------------------------------------- #include<stdio.h> #include<…
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem/A Description Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of…
D. Chip 'n Dale Rescue Rangers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem/D Description A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress.…
C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem/C Description A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that des…
B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem/B Description The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an…
http://codeforces.com/problemset/problem/590/A: 在CF时没做出来,当时直接模拟,然后就超时喽. 题意是给你一个0 1串然后首位和末位固定不变,从第二项开始到倒数第二项,当前的a[i]=(a[i-1],a[i],a[i+1])三项排序后的中间项,比如连续3项为 1 0 1,那么中间的就变为1,然后题目让你输出达到稳定状态时所需的最小步数,不能的话输出-1. 无论给你啥数列,都能达到稳态.所以不可能输出-1: 还有一开始就稳定不变,或经过几次变换而稳定…
B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the…
B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebran…
题目传送门 水 A - Wizards' Duel 题目都没看清就写了,1e-4精度WA了一次... /************************************************ * Author :Running_Time * Created Time :2015/10/25 16:27:20 * File Name :A.cpp ************************************************/ #include <cstdio> #i…
题意: 在一条长度为l的走廊,两个人站在走廊的左右两端分别以p,q的速度走来,问他们相遇时离左端的距离是多少? 思路: 非常简单的暴力题,不解释. 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <fstream> #include <ctime> #include <cmath> #include <cstdlib> #inc…
题目链接: 题目 B. Chip 'n Dale Rescue Rangers time limit per test:1 second memory limit per test:256 megabytes 问题描述 A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they…
D. Top Secret Task time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output A top-secret military base under the command of Colonel Zuev is expecting an inspection from the Ministry of Defence. Acc…
题意:从一点到另一点,前t秒的风向与t秒后风向不同,问到另一点的最短时间 挺难的,做不出来,又参考了别人的代码.先得到终点指向起点的向量,设T秒钟能到.如果T>t则受风1作用t秒,风2作用T-t秒,否则只受风1作用t秒.风作用对向量的影响加到向量上.如果该向量长度小于(船速*T)^2的话,说明T秒能到.T实际上用low和high的mid得出,如果T秒可行,则提高下限. 乱码: //#pragma comment(linker,"/STACK:1024000000,1024000000&qu…
题意:一个数组,一次操作为:除首尾不变,其它的=它与前后数字的中位数,这样对数组重复几次后数组会稳定不变.问要操作几次,及最后的稳定数组. 挺难的题,参考了别人的代码和思路.总的来说就是找01010,010101这样的,分别变为00000,000111.不知道谁发现的将它和异或联系起来.比如对010101异或前一个元素为011111(记为数组b),数组b中连续的1全置0,如果是奇数那么连续的1的中间置1.结果是000100(数组c).再对数组c(除第一个元素)异或前一个元素,得到000111就是…
分析: 三个01组合只有八种情况: 000 s001 s010 0011 s100 s101 1110 s111 s 可以看出只有010,101是不稳定的.其他都是稳定的,且连续地出现了1或0,标记为s. 考虑连续的不稳定串的,例子: 11010100   s        s  110100    s    s    1100 只有两种情况,两个边界是不同(11和00)或者相同(11或者00). 前者中间的不稳定串的长度是2*k,且经过k次将变成11110000,而后者的不稳定串的长度是2*k…
O(1)变换映射,最后一次性替换. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; char s[LEN]; ]; ]; //#define LOCAL int main() { #ifdef LOCAL freopen("in.txt","r",stdin); #endif ; i < ; i++) pos[i] = i; int n, m; scanf(&…
B. Rebranding   The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for th…
C. Median Smoothing   A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and e…
Codeforces Round #485 (Div. 2) F. AND Graph 题目连接: http://codeforces.com/contest/987/problem/F Description You are given a set of size $m$ with integer elements between $0$ and $2^{n}-1$ inclusive. Let's build an undirected graph on these integers in…
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 #541 (Div. 2) http://codeforces.com/contest/1131 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define sqr(x) ((x)*(x)) #define pb push_back #define eb emplace_back…
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++.h> using namespace std; int n,m,k; ; int main() { cin>>n>>m>>k; ;i<=k-;++i) { sum+=(n+(m-))*-(i)*; } cout<<sum<<endl;…
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/D Description Finally it is a day when Arthur has enough money for buying an apartment. H…
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 #539 (Div. 2) 题目链接:https://codeforces.com/contest/1113 A. Sasha and His Trip 题意: n个城市,城市分布在一条直线上且按升序排序,现在有个人开车从一号城市出发,车的油箱容量为v. 在每个城市都可以买油,但价格不一样:第i个城市买1单位的油花费i元.问最终从1到n花费的最少为多少. 题解: 贪心即可,尽量在前面的城市买油,最后一鼓作气到n号城市. 代码如下: #include <bits/…
Codeforces Round #499 (Div. 1) https://codeforces.com/contest/1010 为啥我\(\rm Div.1\)能\(A4\)题还是\(\rm specialist....\) A. Fly 二分答案,送分题. #include<bits/stdc++.h> using namespace std; void read(int &x) { x=0;int f=1;char ch=getchar(); for(;!isdigit(ch…