这套题..除了几何的都出了 完全没时间学几何.杯具 A,B,J 水题不解释 C.Pen Counts 这题的话 写几个不等式限制边得范围就行了 然后枚举最小边 D.Maximum Random Walk 这题的话. 正解是一个n^3的dp dp[i][j][k] 表示第i步走到第j位置最右为k的概率 然后用滚动数组搞,非常简单. 但是还有一种n ^ 2的方法. 被我在比赛中试出来的. 大概是直接记录的第i步走到最右为j的概率 #include <iostream> #include <a…
A.Babs' Box Boutique 给定n个盒子,每个盒子都有长宽高(任意两个盒子长宽高不完全相同),现在选盒子的任意两面,要求x1 <= x2 && y1 <= y2,问最多能选多少盒子满足这需求. 直接dfs暴搞................ #include <cstdio> #include <cstring> #include <string> #include <iostream> #include <c…
A.Babs' Box Boutique 一道简单的dfs搜索题,需要两两比较,然后搜到底,得到最大值就行了.比赛时队友写的,我只负责debug..赛后自己写的.. #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<string> #include<cmath> #include<set> #include&…
Regionals 2013 :: North America - Southeast USA It Takes a Village As a Sociologist, you are studying a certain kingdom. This kingdom has a capitol city, several villages, and roads between them all. Through your sociological studies, you have been a…
2015 UESTC Winter Training #6 Regionals 2010 >> North America - Rocky Mountain A - Parenthesis 给一个长度不多于1000的表达式,只包含小写字母,加法运算,省略乘号的乘法运算和括号,输出去掉多余括号的表达式 括号匹配可以使用栈操作,只有两种情况可以去掉这一对括号: 左括号的左边是左边界.加法符号.左括号,并且右括号右边是有右边界.加法符号.右括号 如果括号内没有加法运算(括号内的括号里,也就是下一级括…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 日期 题目地址:https://leetcode.com/problems/convert-bst-to-greater-tree/description/ 题目描述 Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the…
昨晚各种莫名其妙卡题. 不过细看这套题还挺简单的.全是各种暴力. 除了最后一道题计算几何看起来很麻烦的样子,其他题都是很好写的吧. A. Babs' Box Boutique 题目大意是给出不超过10个的长方体,然后求怎样堆叠使得放的长方体最多. 堆叠的要求是长方体一个一个的往上放,要求接触的面,上面的面长和宽不能比下面的面大 那么每个长方体有三个面,我们就3^n枚举每个长方体使用的哪一面放的. 然后按照这些面的宽进行排序,做一下LIS即可 #include <iostream> #inclu…
题目要求 Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. 题目分析及思路 题目给出一棵二叉搜索树,要求将它转成Greater Tree.定义Greater Tre…
[LeetCode]556. Next Greater Element III 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/next-greater-element-iii/description/ 题目描述: Given a positive 32-bit integer n, you need…
本章施工仍未完成 现在的时间是3.17 0:28,我困得要死 本来今天(昨天?)晚上的计划是把整个四道题的题解写出来,但是到现在还没写完T4的高效算法,简直悲伤. 尝试了用floyd写T4,终于大功告成AC后,看到别人的解题报告说fl能过只是因为测试数据范围小. 好像主要有三种解法,fl,dij,dfs dfs暂时弃,dij写到现在还没完成,先把fl的放上来. 等攻下T4,再施工前面三道题 T4-Floyd: 读完数据以后,只要把文化不兼容的城市的路都堵上,就可以用floyd了 可怜我之前堵路无…