链接:https://ac.nowcoder.com/acm/contest/560/D来源:牛客网 题目描述 Give you a rectangular gird which is h cells high and w cells wide. Each grid is black initially. You can turn some grids into white. A grid A(x,y) is connected with grid B if the coordinate of…
链接:https://pan.baidu.com/s/12gSzPHEgSNbT5Dl2QqDNpA 提取码:fw39 复制这段内容后打开百度网盘手机App,操作更方便哦 D    Grid #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <algorithm> #include &l…
题面见 https://ac.nowcoder.com/acm/contest/700#question 题目大意是有n个单词,有k条替换规则(单向替换),每个单词会有一个元音度(单词里元音的个数)和长度,现在希望利用替换规则(每个规则可使用无限次或不用)将每个单词替换成元音度值最小的单词,如果有多个单词元音度同等最小,那么取长度最小的单词.最后输出替换后的n个单词的元音度值之和与长度之和. 单纯每个点暴力搜,无疑会有爆复杂度的风险 1e5*1e5 ,如果记录搜过的点之后不搜,也会有在一个强连通…
Minieye杯第十五届华中科技大学程序设计邀请赛现场同步赛 I Matrix Again https://ac.nowcoder.com/acm/contest/700/I 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 KK is the engineer responsible for sensor sensing in MINIEYE. KK recently need to u…
A - Beauty of Trees 题意: 链接:https://www.nowcoder.com/acm/contest/119/A来源:牛客网 Beauty of Trees 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 It’s universally acknowledged that there’re innumerable trees in the campus of…
链接:https://www.nowcoder.com/acm/contest/119/F来源:牛客网 Beautiful Land 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 It’s universally acknowledged that there’re innumerable trees in the campus of HUST. Now HUST got a big…
链接:https://www.nowcoder.com/acm/contest/106/K 来源:牛客网 题目描述 It's universally acknowledged that there're innumerable trees in the campus of HUST. Now you're going to walk through a large forest. There is a path consisting of N stones winding its way to…
链接:https://www.nowcoder.com/acm/contest/106/J 来源:牛客网 题目描述 It's universally acknowledged that there're innumerable trees in the campus of HUST. And there are many different types of trees in HUST, each of which has a number represent its type. The doc…
题目描述 It's universally acknowledged that there're innumerable trees in the campus of HUST. Thus a professional tree manager is needed. Your task is to write a program to help manage the trees. Initially, there are n forests and for the i-th forest the…
链接:https://www.nowcoder.com/acm/contest/106/B 来源:牛客网 题目描述 It's universally acknowledged that there're innumerable trees in the campus of HUST. One day Xiao Ming is walking on a straight road and sees many trees line up in the right side. Heights of e…
It’s universally acknowledged that there’re innumerable trees in the campus of HUST.Now HUST got a big land whose capacity is C to plant trees. We have n trees which could be plant in it. Each of the trees makes HUST beautiful which determined by the…
链接:https://www.nowcoder.com/acm/contest/106/K来源:牛客网 题目描述 It’s universally acknowledged that there’re innumerable trees in the campus of HUST. Now you're going to walk through a large forest. There is a path consisting of N stones winding its way to t…
链接:https://www.nowcoder.com/acm/contest/106/J来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 It’s universally acknowledged that there’re innumerable trees in the campus of HUST. And there are many different types o…
#include <bits/stdc++.h> using namespace std; int main() { int T,n,a,b; while(cin>>T) { while(T--) { cin>>n; ; ;i<=n-;i++) { cin>>a>>b; ans=min(ans,a+b); } cout<<ans<<endl; } } ; } C. Captcha Cracker题目大意:给一个字符串…
1352: New Sorting Algorithm Time Limit: 1 Sec  Memory Limit: 128 MB Description We are trying to use a new sorting algorithm to sort a sequence with distinct integers.    This algorithm will be end if the sequence is already in increasing order from…
1350: To Add Which? Time Limit: 1 Sec  Memory Limit: 128 MB Description There is an integer sequence with N integers. You can use 1 unit of cost to increase any integer in the sequence by 1.    Could you tell us the least units of cost to achieve tha…
传送门 题目描述     在空闲时间,张老师习惯性地和菜哭武玩起了取石子游戏,这次的游戏规则有些不同,在他们面前有n堆石子,其中,第i堆石子的个数为a[i],现在制定规则如下:     从张老师开始,两个人轮流取石子,每次可以从任意一堆中取走x个石子,其中x必须严格小于这堆石子的总数并且能够被这堆石子的个数整除,谁先无法继续取走石子就算失败!     例如,只有一堆石子,个数为6,张老师首先可以取走的石子个数为1,2或者3个.     现在给定n堆石子每一堆的石子数,张老师希望你帮他确定在双方最…
Problem B 迷宫寻宝 Accept: 52    Submit: 183Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description 洪尼玛今天准备去寻宝,在一个n*n (n行, n列)的迷宫中,存在着一个入口.一些墙壁以及一个宝藏.由于迷宫是四连通的,即在迷宫中的一个位置,只能走到与它直接相邻的其他四个位置(上.下.左.右).现洪尼玛在迷宫的入口处,问他最少需要走几步才能拿到宝藏?若永远无法拿到宝藏,则输出-…
问题 B: B - 烦恼先生打麻将 时间限制: 1 Sec  内存限制: 256 MB提交: 8  解决: 5[提交][状态][讨论版] 题目描述 输入 6 6 Z D 1S 1S 9W 5W 2S 6S 2W 1S X B 2W 1W 7W 1T 6W 3T B BB 4S 3T 8W X 3T 4T 5T 9T 8T 2W B 5W 7W Z 9W B 9T 3S 7W 9S 8T 6W F 4T 9W 4T D 2T 2T 9T 7W 7S 4T 4S 3W N 9T BB 7S X 1S…
Now Loading!!! Time Limit: 1 Second      Memory Limit: 131072 KB DreamGrid has  integers . DreamGrid also has  queries, and each time he would like to know the value of   for a given number , where , . Input There are multiple test cases. The first l…
Problem 1603 - Minimum Sum Time Limit: 2000MS   Memory Limit: 65536KB   Total Submit: 564  Accepted: 157  Special Judge: No Description There are n numbers A[1] , A[2] .... A[n], you can select m numbers of it A[B[1]] , A[B[2]] ... A[B[m]]  ( 1 <= B[…
Another Server 时间限制:1秒 空间限制:262144K 题目描述 何老师某天在机房里搞事情的时候,发现机房里有n台服务器,从1到n标号,同时有2n-2条网线,从1到2n-2标号,其中第i条网线双向连接着 服务器和号服务器,在一个单位时间内最多能够承受x_i个单位流量. 显然这些服务器之间要进行信息交换,为了测试服务器的抗压能力,你需要帮何老师计算出1号服务器在一个单位时间内最多能向n号服务器发送多少个单位流量的数据,这里认为数据的传输是瞬间完成的. (该图引用自百度百科) 输入描…
链接:https://www.nowcoder.com/acm/contest/91/C来源:牛客网没有账号的同学这样注册,支持博主 题目描述 给定两个长度为n的序列,ai, bi(1<=i<=n), 通过3种魔法使得序列a变换为序列b,也就是ai=bi(1<=i<=n). 魔法1: 交换ai和aj,i!=j 首先通过若干次的魔法1将序列a变换成序列c 魔法2: 对1个数乘2或者加1 魔法3: 对1个数除以2或者减1,如果是奇数,则不能除以2 若ci>bi, 则只能对ci实施…
题目描述 给一个数组 a,长度为 n,若某个子序列中的和为 K 的倍数,那么这个序列被称为“K 序列”.现在要你 对数组 a 求出最长的子序列的长度,满足这个序列是 K 序列.  输入描述: 第一行为两个整数 n, K, 以空格分隔,第二行为 n 个整数,表示 a[1] ∼ a[n],1 ≤ n ≤ 10 5 , 1 ≤ a[i] ≤ 10 9 , 1 ≤ nK ≤ 10 7 输出描述: 输出一个整数表示最长子序列的长度 m 示例1 输入 7 5 10 3 4 2 2 9 8 输出 6写的时候暴…
先给你1~N的N个数 再给你每种最多50个的条件(ai,bi,ci) 或者[ai,bi,ci] (ai,bi,ci)表示下标ai到bi的最小值必为ci [ai,bi,ci]表示下标ai到bi的最大值必为ci 问你能不能有一种1~N的排列满足要求且字典序最小 首先这是一个左边n个 右边n个的二分图 左边表示位置 右边表示值 每个位置只能对应一个值 且要完美匹配才有解 那么如何建边? 我们用l[i] r[i]两个数组表示值i必定出现的最右左界和最左右界 用minn[i] maxn[i]两个数组表示下…
给你一个一般图 保证每条边的一端下标不大于30 问最小覆盖集的大小为多少 爆搜:枚举前30个点是否在覆盖集内 剪枝1:如果不在的话 那么他所连的下标大于30的点都必须选 剪纸2:最优解剪枝 #include<bits/stdc++.h> using namespace std; int n, m; bitset<> G[], em; int cnt, ans; > a) { if (a.count() >= ans) { return; } || o > ) {…
给你一个一共由两种边的完全图 要求你求1到N的最短路 q队列为前沿队列(已探索过且最外围的点)  p队列为未探索队列(未探索过的点) depth这个数组的用法并不是代表实际上这个点在第几层 而是防止死循环 保证每次通过前沿的一个点都只会遍历p中每个点一次 #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ; ; int n,m,a,b,nm,qwq; int head[maxn]; ll dis[maxn…
链接:https://ac.nowcoder.com/acm/contest/3/J 来源:牛客网 Just A String 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 何老师手中有一个字符串S,他发现这个字符串有一个神奇的性质,取出一个长为i的前缀(就是由S的前i个字符顺序构成的字符串)prei和一个长为j的后缀(就是由S的后j个字符顺序构成的字符串)sufj之后,总是存在三个字…
链接:https://ac.nowcoder.com/acm/contest/3/K 来源:牛客网 Keep In Line 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 又到饭点了,SK同学靠着惯性走到了食堂,但长长的队伍顿时让他失去了食欲.突然,他注意到某个窗口前的队伍里明显存在插队的现象,于是他默默记录下了同学们进队和出队的变化. 对于进队,SK同学只知道队伍里多了一个人,并不知…
链接:https://ac.nowcoder.com/acm/contest/3/B 来源:牛客网 Borrow Classroom 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 每年的BNU校赛都会有两次赛前培训,为此就需要去借教室,由于SK同学忙于出题,这个事情就由小Q同学来跑腿.SK同学准备从宿舍出发,把借教室的单子交给小Q同学让他拿去教务处盖章,但是何老师突然发现SK同学好像借…