
ACM ---- 题解
米诺minoz
这个作者很懒,什么都没留下…
展开
-
最大子矩阵和(To the max) 杭电1081
To the MaxDescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum ...原创 2019-10-09 10:53:01 · 361 阅读 · 0 评论 -
春季训练个人赛 -2
1、 Height OrderingMrs. Chambers always has her class line up in height order (shortest at the front of the line). EverySeptember a new class of exactly 20 3rd graders arrive, all of different height...原创 2019-03-04 11:13:24 · 700 阅读 · 0 评论 -
2019-假期第三场(2019.2.1)
7001 Bus ProblemACM Bus company runs a large bus network. To go from city A to city B, there could be a expressroute with no stops between the two cities. There could also be local routes with stops...原创 2019-02-09 14:45:14 · 258 阅读 · 0 评论 -
2019 - 假期第二场(2019.1.25)
1、 Almost Sorted ArrayWe are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selectionsort, bubble sort, etc. But sometimes it is an overkill to use these al...原创 2019-01-25 21:56:45 · 307 阅读 · 0 评论 -
2019-假期第一场(2019.1.14)
1、sum of powerDescription InputInput contains two integers n,m(1≤n≤1000,0≤m≤10).OutputOutput the answer in a single line.Sample Input10 0Sample Output10 题意:求 的和求余 mod (...原创 2019-01-17 11:05:36 · 199 阅读 · 0 评论 -
组队赛NO.13
1、Automated Checking Machine6821 Automated Checking MachineThe Internet Computer Parts Company (ICPC) is an on-line shop that sells computer parts. Pairsof in-line electrical connectors are among ...原创 2018-11-30 20:06:00 · 529 阅读 · 0 评论 -
A - Stars (树状数组)
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and ...原创 2018-11-23 21:54:19 · 381 阅读 · 0 评论 -
CodeForces 996B
Allen wants to enter a fan zone that occupies a round square and has nn entrances.There already is a queue of aiai people in front of the ii-th entrance. Each entrance allows one person from its que...原创 2018-11-17 09:30:51 · 258 阅读 · 0 评论 -
字典树详解
转一、入门介绍:1、 Trie树(字典树)定义:又称单词查找树,Trie 树,是一种树形结构,是一种哈希树的变种。或者按顺序输入 at,cash,app,apple,aply,ok 建一颗字典树 2:应用:典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计3:优缺点:它的优点是:利用字符串的公共前缀来...原创 2018-11-16 21:49:58 · 2327 阅读 · 0 评论 -
二叉树的先序、中序、后序遍历(递归+非递归)
一、 先序遍历:1、递归算法: 根左右int PreOrder(BiTree p) /* 先序遍历二叉树*/{ if ( p!= NULL ) { printf("%c", p->data); PreOrder( p->lchild ) ; PreOrder( p->rchild) ; }...原创 2018-11-13 20:56:53 · 389 阅读 · 0 评论 -
组队赛——NO.5
1、Which Base is it Anyway?Programming languages such as C++ and Java can prefix characters to denote the base of constantinteger values. For example, hexadecimal (base 16) constants are preceded by...原创 2018-11-14 15:39:38 · 343 阅读 · 0 评论 -
组队赛——NO.4
1、题目链接Hidden Password题意:给定两个字符串 s、t,查找 s 字符在 t 中出现的位置(保证都是大写字母)需要满足:(1)、s中按顺序出现字符的位置应该满足递增 例如:ABC HAPPYBIRTHDAYCACEY t 串中首先出现 A,之后再出现 B,再出现 C ,满足 ...原创 2018-11-13 23:06:22 · 210 阅读 · 0 评论 -
组队赛 NO.2
1、D - Garbage DisposalDescriptionEnough is enough. Too many times it happened that Vasya forgot to dispose of garbage and his apartment stank afterwards. Now he wants to create a garbage disposa...原创 2018-11-02 20:56:36 · 458 阅读 · 0 评论 -
小希的迷宫 && Is It A Tree?——并查集 / 图转化成树
一、无向图转化成树 (也可用并查集)Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以...原创 2018-11-02 20:38:45 · 357 阅读 · 0 评论 -
组队赛——NO.1 (Accepted)
1、N-th Largest Value题目链接题意:找出倒数第三大数字CODE:#include <iostream>#include <cstdio>#include <cmath>#include <cstring>#include <cstdlib>#include <algorithm>...原创 2018-10-31 16:28:36 · 235 阅读 · 0 评论 -
用JAVA 实现卡特兰数
卡特兰数详解JAVA 实现大数 详解 例1:B - Game of ConnectionsThis is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, ... , 2n - 1, 2n consecutively in clockwise order on the gr...原创 2018-10-23 13:03:59 · 1626 阅读 · 2 评论 -
春季个人训练赛 5(广工新生赛)
1、A -hzy 和zsl 的生存挑战Descriptionzsl 和hzy 来到了臭臭城堡,打算挑战臭臭城堡的大魔王hyz,大魔王hyz设置了这样的一个挑战:1. zsl 和hzy两个人各自来到一间密室,期间两人无法以任何形式交流2. 大魔王hyz会随机在两个人的脑海里各发送一个数字,0或者是13. zsl 和 hzy 需要猜对这俩个数字才算通关,但是大魔王hyz觉得人生不...原创 2019-03-19 15:36:17 · 304 阅读 · 0 评论 -
最小生成树例题详解
ONE:题目描述题意:求n个顶点间的最小生成树,使整个拓扑路径和最小用 Prim 模板来写#include <iostream>#include <cstdio>#include <cmath>#include <cstring>#include <algorithm>#include <set>...原创 2019-03-07 16:14:43 · 1669 阅读 · 0 评论 -
最短路例题
最短路请戳ONE:题目来源 最短路 Problem Description 在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗? Input 输入包括多组数据。每组数据第一行是...原创 2019-03-07 20:50:18 · 487 阅读 · 0 评论 -
树链剖分代码(洛谷3384)
题目链接题意:树链剖分模板题 (树链剖分+线段树)准备工作:第一步: 定义声明// 链式前向星存图 (**** 记得开2倍空间 ****)struct EDGE{ int to; int next;}edge[MAXX<<1];// 线段树结构体,存和、lazy标记 (**** 记得开4倍空间 ****)struct NODE{ ...原创 2019-08-13 09:14:40 · 391 阅读 · 0 评论 -
As Easy as CAB(2016 ICPC Mid-Central USA Region)
题意:输入 字母(用变量名 AA 代替) n // 分别代表这个串中最大的字母(这个是按照原有字母表的顺序确定的) 、 n个串按照 新规定字母表的大小顺序 给出由小到大排序好的 n 个字符串,求 a - AA 之间的由小到大的新顺序思路:每相邻两行进行比较该列字母的大小遇到当前比较的两个字母不同时,用 ch[i][j] 标记一下,表示第i行与第j行不...原创 2019-08-15 10:57:33 · 328 阅读 · 0 评论 -
D. Take Your Seat
D. Take Your SeatDuha decided to have a trip to Singapore by plane.The airplane had原创 2019-08-19 11:32:04 · 621 阅读 · 0 评论 -
图的存储 - 邻接矩阵.邻接表.链式前向星
对于ACM图论方面的题目总是免不了首先要建图存图,使用合适的存图方式不但是AC的必要条件,解题事半功倍。以下主要分析三种常见的存图方式的优缺点以及代码实现目录一、邻接矩阵1.定义12.存图思想13.表现形式14.代码15.优缺点1二、邻接表1.定义22.存图思想23.表现形式24.代码25.优缺点2三、链式前向星1.定义32.存图...原创 2019-07-30 11:56:20 · 900 阅读 · 0 评论 -
Coprime Sequence (HDU 6025)
Coprime SequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 3655Accepted Submission(s): 1687Problem DescriptionDo you know wh...原创 2019-05-30 10:06:57 · 216 阅读 · 0 评论 -
威佐夫博弈
一、有两堆各若干的物品,两人轮流从其中一堆取至少一件物品,至多不限,或从两堆中同时取相同件物品,规定最后取完者胜利二、分析:首先我们根据条件来分析博弈中的奇异局势第一个(0 , 0),先手输,当游戏另一方面对( 0 , 0)时,他没有办法取了,那么肯定是先手在上一局取完了,那么输。 或者是当游戏另一方面对 (0,k)或 (k,0)时,先手一定输,后手可以...原创 2019-04-25 20:53:24 · 208 阅读 · 0 评论 -
尼姆博弈
一、有任意堆物品,每堆物品的个数是任意的,双方轮流从中取物品,每一次只能从一堆物品中取部分或全部物品,最少取一件,取到最后一件物品的人获胜。二、结论:把每堆物品数全部异或起来,如果得到的值为0,那么先手必败,否则先手必胜(此时异或值为不为0的数)三、CODE#include <algorithm>#include <iostream>#includ...原创 2019-04-25 20:43:25 · 193 阅读 · 0 评论 -
最大子段和
动态规划1049 最大子段和N个整数组成的序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续子段和的最大值。当所给的整数均为负数时和为0。例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13。和为20。收起输入第1行:整数序列的长度N(2 <= N <= 50000)第2 - N + ...原创 2019-04-16 16:57:57 · 194 阅读 · 0 评论 -
HDU 1238 Substrings
DescriptionYou are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given st...原创 2019-04-12 18:37:53 · 230 阅读 · 0 评论 -
上海高校程序设计竞赛暨第十七届上海大学程序设计春季联赛
链接:https://ac.nowcoder.com/acm/contest/551#question一、CSL 爱烫头题目描述又到了一年一度的樱花节,CSL 的同学邀请 CSL 一起去赏樱花。于是爱美的 CSL 决定好好打扮一下自己。看了看自己日益减少的头发,CSL 觉得再不烫头就来不及了,于是拿出了所有的奖学金,想要做个头发。由于头发实在太少,一般的理发店无法处理,CSL 不得已要...原创 2019-03-31 19:40:09 · 400 阅读 · 0 评论 -
春季个人训练赛 9
**A - Penney Game(4873)**Penney’s game is a simple game typically played by two players. One version of the game calls for eachplayer to choose a unique three-coin sequence such as HEADS TAILS HEA...原创 2019-03-30 18:39:28 · 386 阅读 · 0 评论 -
Pen Counts(UVALIVE 6174)
Sample Input51 32 113 124 1005 9999Sample Output1 12 53 43925 4165834题意:用长度为 n 的绳子围三角形同一三角形的旋转是相同的,反射是不同的意思就是,对于等腰和等边三角形来说,不论怎么旋转只能算一种,其余的算两种思路:设定 a<=b<...原创 2019-03-26 15:37:10 · 206 阅读 · 0 评论 -
Old Fafhioned Typefetting
UVALIVE 4875In Olden Days, before digital typesetting (before Babbage, even), typesetting was an art, practicedby highly skilled craftsmen. Certain character combinations, such as a-e or f-i were ty...原创 2019-04-03 21:03:38 · 290 阅读 · 0 评论 -
Faulhaber's Triangle (UVALIVE 6176)
Faulhaber’s Triangle ( UVALIVE 6176)InputThe first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data setsthat follow. Each data set should be processed identic...原创 2019-03-25 20:39:13 · 248 阅读 · 0 评论 -
春季个人训练赛-6
1、 Bit String ReorderingYou have to reorder a given bit string as specified. The only operation allowed is swapping adjacentbit pairs. Please write a program that calculates the minimum number of sw...原创 2019-03-18 11:58:52 · 329 阅读 · 0 评论 -
春季个人训练赛-3、4
1、 ParenthesesA bracket is a punctuation mark, which is used in matched pairs, usually used within articles orprograms. Brackets include round brackets, square brackets, curly brackets, angle bracke...原创 2019-03-17 20:10:59 · 409 阅读 · 0 评论 -
USACO 1.4.4 Mother's Mil 母亲的牛奶
Description农民约翰有三个容量分别是A,B,C升的桶,A,B,C分别是三个从1到20的整数,最初,A和B桶都是空的,而C桶是装满牛奶的。有时,约翰把牛奶从一个桶倒到另一个桶中,直到被灌桶装满或原桶空了。当然每一次灌注都是完全的。由于节约,牛奶不会有丢失。 写一个程序去帮助约翰找出当A桶是空的时候,C桶中牛奶所剩量的所有可能性。Input单独的一行包括三个整数A,B和C。O...原创 2018-09-30 15:49:28 · 237 阅读 · 0 评论 -
国庆个人赛——NO.7
1、Codeforces-716B Complete the WordZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where ea...原创 2018-10-08 20:37:40 · 265 阅读 · 0 评论 -
国庆个人赛——NO.6
1、Codeforces-714AToday an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!Sonya is an owl and she sleeps during the day and stay awake from m...原创 2018-10-08 19:50:38 · 184 阅读 · 0 评论 -
全排列(下一个排列,算法)
给出一个字符串S(可能有重复的字符),按照字典序从小到大,输出S包括的字符组成的所有排列。例如:S = “1312”, 输出为:1123 1132 1213 1231 1312 1321 2113 2131 2311 3112 3121 3211 Input 输入一个字符串S(S的长度 &amp;amp;lt;= 9,且只包括0 - 9的阿拉伯数字) Output 输出S所包含...原创 2018-04-30 20:01:02 · 1523 阅读 · 0 评论 -
暴力求解法--简单枚举(Division,UVa 725)
输入正整数 n ,按从小到大的顺序输出所有 形如 abcde/fghij = n 的表达式,其中 a~j 恰好为数字 0~9 的一个排列(可以有 前导 0),2&lt;=n&lt;=79 样例输入 62 样例输出 79546/ 01283 = 62 94736/ 01528 = 62/*是紫书上的一个 例题首先方法就是 枚举,但是枚举时对问题进行一些分析能让代码简洁本题就...原创 2018-05-02 20:23:32 · 418 阅读 · 0 评论