Street Lamps   Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is a lamp in a block, it will light it’s block and the direct adjacent blocks. For example, if there is a lamp at block 3, it will light…
Rock-Paper-Scissors   Rock-Paper-Scissors is a two-player game, where each player chooses one of Rock, Paper, or Scissors. Here are the three cases in which a player gets one  point: ­          Choosing Rock wins over a player choosing  scissors. ­  …
Runtime Error   Bahosain was trying to solve this simple problem, but he got a Runtime Error on one of the test cases, can you help him by solving it? Given an array of N non-negative integers and an integer K, your task is to find two integers X and…
Heavy Coins   Bahosain has a lot of coins in his pocket. These coins are really heavy, so he always tries to get rid of some of the coins by using them when paying for the  taxi. Whenever Bahosain has to pay S pennies for the taxi driver, he tries to…
Travelling Salesman   After leaving Yemen, Bahosain now works as a salesman in Jordan. He spends most of his time travelling between different cities. He decided to buy a new car to help him in his job, but he has to decide about the capacity of the…
Epic Professor   Dr. Bahosain works as a professor of Computer Science at HU (Hadramout    University). After grading his programming exam, he noticed that most of the students have failed. Since this is the last semester for him teaching in Yemen, D…
课堂限时训练-简易计算器·mini dc 实验题目 采用后缀表达式法,设计一个建议计算器,实现+.-.*./四种运算. 代码实现 码云链接 关键代码部分及结果如下: 实验分析 首先,分析一下后缀表达式的算法原理:后缀表达式的运算符位于与其相关的操作数之后:中缀和前缀同理. 举例说明: (3 + 4) × 5 - 6 就是中缀表达式 - × + 3 4 5 6 前缀表达式 3 4 + 5 × 6 - 后缀表达式 本实验中采用栈实现这一取数顺序--先进后出.后进先出. 具体为:从左至右扫描表达式,遇…
洛谷P2507 [SCOI2008]配对 题解(dp+贪心) 标签:题解 阅读体验:https://zybuluo.com/Junlier/note/1299251 链接题目地址:洛谷P2507 [SCOI2008]配对 感觉是道很好的推断题 贪心 想到贪心的结论就很容易,没想到就很难做出来了 结论:对\(A,B\)数组分别排序之后,在\(A\)中选第\(i\)个数,与之配对的数一定在\(B[i-1]\)~\(B[i+1]\)内 其实证明是很好证的,在与你是否往这方面想了... 因为题目有一个很…
洛谷P1484 种树&洛谷P3620 [APIO/CTSC 2007]数据备份 题解(堆+贪心) 标签:题解 阅读体验:https://zybuluo.com/Junlier/note/1329957 题目链接地址: 洛谷P1484 种树 洛谷P3620 [APIO/CTSC 2007]数据备份(各大oj多倍经验) 照例吐槽 两道基本一模一样的题,只是第二道要差分顺便思维稍微向这边转化一下... 我觉得这两个题思维很不错啊!很\(Noip\ T2\)的样子... 话不多说将题解 贪心+堆优化 肯…
题意: 有很多台机器,可以把物件从一种状态改装成另一种状态,初始全为\(0\),最终状态全为\(1\),让你可以拼凑机器,请问最大总性能为多少,且要求输出方案. 题解: 这道题是真的水啊,我不想写太多,加一点吧.我们发现,把一个机器当作点来看的话一个机器的加工数即为点权.而点权在网络流的题目里是\(SB\),于是考虑转化为边权.而且我们要控制流量,于是考虑进行拆点. 把点拆开后,因为初始是全为\(0\)的,所以将所有初始状态为\(0\)的机器的入点与超级源点连边,而所有最终状态为\(1\)的机器…
A:HDU 1060 Leftmost Digit(求N^N的第一位数字 log10的巧妙使用) B:(还需要研究一下.....) C:HDU 1071 The area(求三个点确定的抛物线的面积,其中一个点是顶点) D:HDU 1077 Catching Fish(用单位圆尽可能围住多的点) E:HDU 1099 Lottery (求数学期望) F:HDU 1110 Equipment Box (判断一个大矩形里面能不能放小矩形) G:HDU 1155 Bungee Jumping(物理题,…
随着评讲的进行代码和题解会逐步放上来 2018天梯赛第一次训练 1001 : 进制转换 Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByteTotal Submit: 78            Accepted: 42 Description 输入一个十进制数N,将它转换成R进制数输出. Input 输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(2<=R<=16) Output 为每个测…
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is a lamp in a block, it will light it’s block and the direct adjacent blocks. For example, if there is a lamp at block 3, it will light the blocks 2, 3…
题目链接: C - Grid of Lamps Time Limit:1000MSMemory Limit: 0KB 问题描述 We have a grid of lamps. Some of the lamps are on, while others are off. The luminosity of a row/column is the number of its lighted lamps. You are given a permutation of the luminositie…
199. Beautiful People time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard output: standard The most prestigious sports club in one city has exactly N members. Each of its members is strong and beautiful. More precisely, i-t…
Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描述 Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she…
题目链接:http://acm.hust.edu.cn/vjudge/contest/131124#overview 贴了链接这里就不上原题的描述了. A: B: 分析:这里用到简单的拓扑排序的算法.这里你会发现它给出的胜负关系不是线性的,无法用一个线性表存储,因此这里自然想到构图.然后用到拓扑排序的原理,我们建立有向图,用v1 —>v2表示v2战胜了v1,那么在建图完成之后,这个图中入度为0的点就是最后一名,因为它没有战胜任何人.如果当前图入度为0的点有多个,就按照题目要求将小数放在前面.然后…
ACM暑期集训总结报告 不知不觉,ACM暑期集训已经过去了一个月了(其实我还差几天才够一个月,因为最后几天要回家办助学贷款,所以没坚持到最后,当了个逃兵.....[汗])也到了结束的时候.在这一个月中, 有压力,有感触,也有喜悦.收获了很多,反思了很多. 知识方面,这一个月中, 主要是看了DP的内容,包括基础DP(主要是背包), 状压DP, 数位DP(掌握的不好), 树形DP.另外,每周有几场训练赛,通过训练赛的题目,既重温了已经有些模糊的一些知识点,学习到了新的知识点.最后,还参加了一场CCP…
D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For each string s consisting of characters '0' and '1' one can define four integers a00, a01, a10 and a11, where axy is…
Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描写叙述 Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because s…
题目链接:http://codeforces.com/problemset/problem/632/C C. The Smallest String Concatenation time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You're given a list of n strings a1, a2, ..., an. Y…
这次周赛题目拉了CF315和CF349两套题. 因为我代码模板较长,便只放出关键代码部分 #define ll long long #define MMT(s,a) memset(s, a, sizeof s)#define GO(i,a,b) for(int i = (a); i < (b); ++i)#define GOE(i,a,b) for(int i = (a); i <= (b); ++i)#define OG(i,a,b) for(int i = (a); i > (b);…
问题A:Hello SUST! 知识点:基本输入输出 C/C++: #include <stdio.h> int main() { int n; scanf("%d", &n); while(n --) { printf("Hello SUST!\n"); } ; } 问题B:计算A+B 知识点:基本输入输出 C/C++: #include <cstdio> int main() { int a, b; while(~scanf(&q…
链接 题目描述 恶魔猎手尤迪安野心勃勃,他背叛了暗夜精灵,率领深藏在海底的娜迦族企图叛变.守望者在与尤迪安的交锋中遭遇了围杀,被困在一个荒芜的大岛上.为了杀死守望者,尤迪安开始对这个荒岛施咒,这座岛很快就会沉下去.到那时,岛上的所有人都会遇难.守望者的跑步速度为17m/s,以这样的速度是无法逃离荒岛的.庆幸的是守望者拥有闪烁法术,可在1s内移动60m,不过每次使用闪烁法术都会消耗魔法值10点.守望者的魔法值恢复的速度为4点/s,只有处在原地休息状态时才能恢复. 现在已知守望者的魔法初值M,他所在…
讲讲我的做法 题目大意:对一个字符串进行折叠是它长度最小 看一眼数据范围:哇!字符串长度不超过100!这是一道省选题,不可能给你太宽裕的时限,所以,题目基本暗示你要用\(n^{3}\)多一些的算法复杂度. 这是一道最优化的题目,常见求最优化问题的算法比如贪心,模拟,枚举我都想不出什么好办法,唯独觉得像一道区间\(dp\) 区间\(dp\)的分析 解释状态 我们用\(f[i][j]\)表示\(i\)到\(j\)这个区间内最小的长度 首先,我们可以把\(i\)~\(j\)这个区间的字符串拆成2部分处…
Weird Cryptography Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u  Gym 100935B Description standard input/output Khaled was sitting in the garden under an apple tree, suddenly! , well... you should guess what happened, a…
Problem C Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Description 度熊手上有一本神奇的字典,你可以在它里面做如下三个操作: 1.insert : 往神奇字典中插入一个单词 2.delete: 在神奇字典中删除所有前缀等于给定字符串的单词 3.search: 查询是否在神奇字典中有一个字符串的前缀等于给定的字符串   Input 这里仅有一组测试数据.第一行输入一个…
约翰认为字符串的完美度等于它里面所有字母的完美度之和.每个字母的完美度可以由你来分配,不同字母的完美度不同,分别对应一个1-26之间的整数. 约翰不在乎字母大小写(也就是说字母A和a的完美度相同).给定一个字符串,输出它的最大可能的完美度.例如:dad,你可以将26分配给d,25分配给a,这样整个字符串完美度为77. 收起   输入 输入一个字符串S(S的长度 <= 10000),S中没有除字母外的其他字符. 输出 由你将1-26分配给不同的字母,使得字符串S的完美度最大,输出这个完美度. 输入…
题意简述: 思路: 直接考虑把人和物品都看成二维平面上面的a,ba,ba,b两类点,然后一个aaa和bbb匹配的条件是xa≤xb&&ya≤ybx_a\le x_b\&\&y_a\le y_bxa​≤xb​&&ya​≤yb​,要求最后选出的bbb的横坐标之和最小. 这样的话,我们把a,ba,ba,b两类点分别按照xxx坐标排序,然后用类似归并排序的方法贪心选就行了. 贪心策略:从所有能够跟当前的bbb匹配的aaa类点中选一个yyy坐标最大的出来. 用setse…
题目背景 Lj的朋友WKY是一名神奇的少年,在同龄人之中有着极高的地位... 题目描述 他的老师老王对他的程序水平赞叹不已,于是下决心培养这名小子. 老王的训练方式很奇怪,他会一口气让WKY做很多道题, 要求他在规定的时间完成. 而老王为了让自己的威信提高,自己也会把这些题都做一遍. WKY和老王都有一个水平值,他们水平值的比值和做这些题 所用时间的比值成反比.比如如果WKY的水平值是1,老王的水平值是2 那么WKY做同一道题的时间就是老王的2倍. 每个题目有他所属的知识点,这我们都知道, 比如…