USACO DP动规 完整版

合集下载

状压DP(超详细!!!)

状压DP(超详细!!!)

状压DP(超详细)⼀、定义总述状态压缩动态规划,就是我们俗称的状压DP,是利⽤计算机⼆进制的性质来描述状态的⼀种DP⽅式。

很多棋盘问题都运⽤到了状压,同时,状压也很经常和BFS及DP连⽤。

状压dp其实就是将状态压缩成2进制来保存其特征就是看起来有点像搜索,每个格⼦的状态只有1或0 ,是另⼀类⾮常典型的动态规划举个例⼦:有⼀个⼤⼩为n*n的农⽥,我们可以在任意处种⽥,现在来描述⼀下某⼀⾏的某种状态:设n = 9;有⼆进制数 100011011(九位),每⼀位表⽰该农⽥是否被占⽤,1表⽰⽤了,0表⽰没⽤,这样⼀种状态就被我们表⽰出来了:见下表所以我们最多只需要 2^(n + 1) - 1的⼗进制数就好(⼆进制形式是n个1)现在我们有了表⽰状态的⽅法,但⼼⾥也会有些不安:上⾯⽤⼗进制表⽰⼆进制的数,枚举了全部的状态,DP起来复杂度岂不是很⼤?没错,状压其实是⼀种很暴⼒的算法,因为他需要遍历每个状态,所以将会出现2^n的情况数量,不过这并不代表这种⽅法不适⽤:⼀些题⽬可以依照题意,排除不合法的⽅案,使⼀⾏的总⽅案数⼤⼤减少从⽽减少枚举为了更好的理解状压dp,⾸先介绍位运算相关的知识。

1. ’&’符号,x&y,会将两个⼗进制数在⼆进制下进⾏与运算(都1为1,其余为0)然后返回其⼗进制下的值。

例如3(11)&2(10)=2(10)。

2. ’|’符号,x|y,会将两个⼗进制数在⼆进制下进⾏或运算(都0为0,其余为1)然后返回其⼗进制下的值。

例如3(11)|2(10)=3(11)。

3. ’^’符号,x^y,会将两个⼗进制数在⼆进制下进⾏异或运算(不同为1,其余为0)然后返回其⼗进制下的值。

例如3(11)^2(10)=1(01)。

4. ’~’符号,~x,按位取反。

例如~101=010。

5. ’<<’符号,左移操作,x<<2,将x在⼆进制下的每⼀位向左移动两位,最右边⽤0填充,x<<2相当于让x乘以4。

电动执行机构操作步骤

电动执行机构操作步骤

常州施耐德电动执行机构操作步骤本操作分手动操作和电动操作两种。

一、手动操作操作前,压下手动/电动切换手柄,使其处于手动位置,松开手柄,手柄将恢复到初始位置。

旋转手轮直到与离合器啮合,此时可用手轮操作阀门。

二、电动操作1、现场操作:顺时针旋转红色旋钮到“现场”位置,执行机构处于现场操作模式。

此时可通过相邻黑色旋钮进行执行机构的现场开、关操作,将黑色旋钮旋转到“停”位置即可停止阀门的电动操作。

2、远控操作:逆时针旋转红色旋钮到“远控”位置,执行机构控制处于远程控制模式,只能接受远程操作指令,此时黑色旋钮上“开”、“关”操作失效。

在中控室登录SCADA系统,点击需要操作的阀门,在弹出的菜单中进行相应的开、关、停操作。

Limitorque电动执行机构操作步骤本操作分手动操作和电动操作两种。

一、手动操作为了用手轮操作执行机构,压下离合器手柄并且同时慢慢地旋转手轮直到离合器全部啮合为止。

此时可以放开此手柄并且它会返回它的初始位置,但是离合器将由弹簧加载的插销保持在手轮方式,现在就可以手动操作开、关了。

此后,执行机构只能通过使电机得电来返回自动操作,这将使弹簧加载的插销跳闸并使离合器与手轮脱开并且重新与齿轮驱动器啮合。

二、电动操作1、就地操作:把红色选择旋钮置于“LOCAL”(就地)位置,然后通过黑色控制旋钮选择“OPEN”(开)或“CLOSE”(关)。

如果选择了保持控制,当此控制开关被放开时,执行机构还会连续地运行,但是它可以在任何时候通过把红色选择旋钮置于“STOP”(停止)位置来使之停止,或者用黑色控制旋钮使之反向或停止。

如果选择了非保持控制点动则通过把黑色旋钮保持在所要求的位置“OPEN”或“CLOSE”,按需要确定其时间的长短,这样就可以把执行机构点动(inche)到任何中间位置。

当放开旋钮时执行机构就停止。

2、远程控制:要把控制转换到远程控制,可把红色选择旋钮置于“REMOTE”(远程)位置。

就地的“OPEN/CLOSE”操作就被制止。

微玛肯控制头带滑动开关手册说明书

微玛肯控制头带滑动开关手册说明书

Page 151 Winthrop RoadChester, Connecticut 06412-0684Phone: (860) 526-9504Internet: Sales e-mail: autosale@Customer Service e-mail: custserv@Configuration Guide:6-button WeCan® Control Head with Slide Switch©2009 Whelen Engineering Company Inc.Form No.14285B (022117)A u t o m o t i v e : S i r e n s /S w i t c h e s®ENGINEERING COMPANY INC.For warranty information regarding this product, visit /warrantyDANGER! Sirens produce extremely loud emergency warning tones! Exposure to these tones without proper and adequate hearing protection, could cause ear damage and/or hearing loss! The Occupational Safety & Health Administration () provides information necessary to determine safe exposure times in Occupational Noise Exposure Section 1910.95. Until you have determined the safe exposure times for your specific application,operators and anyone else in the immediate vicinity should be required to wear an approved hearing protection device. Failure to follow this recommendation could cause hearing loss!•Proper installation of this product requires the installer to have a good understanding of automotive electronics, systems and procedures.•Whelen Engineering requires the use of waterproof butt splices and/or connectors if that connector could be exposed to moisture.•Any holes, either created or utilized by this product, should be made both air- and watertight using a sealant recommended by your vehicle manufacturer.•Failure to use specified installation parts and/or hardware will void the product warranty.•If mounting this product requires drilling holes, the installer MUST be sure that no vehicle components or other vital parts could be damaged by the drilling process. Check both sides of the mounting surface before drilling begins. Also de-burr the holes and remove any metal shards or remnants. Install grommets into all wire passage holes.•If this manual states that this product may be mounted with suction cups, magnets, tape or Velcro®, clean the mounting surface with a 50/50 mix of isopropyl alcohol and water and dry thoroughly.•Do not install this product or route any wires in the deployment area of your air bag. Equipment mounted or located in the air bag deployment area will damage or reduce the effectiveness of the air bag, or become a projectile that could cause serious personal injury or death. Refer to your vehicle owner’s manual for the air bag deployment area. The User/Installer assumes full responsibility to determine proper mounting location, based on providing ultimate safety to all passengers inside the vehicle.•For this product to operate at optimum efficiency, a good electrical connection to chassis ground must be made. The recommended procedure requires the product ground wire to be connected directly to the NEGATIVE (-) battery post (this does not include products that use cigar power cords).•If this product uses a remote device for activation or control, make sure that this device is located in an area that allows both the vehicle and the device to be operated safely in any driving condition.•It is recommended that these instructions be stored in a safe place and referred to when performing maintenance and/or reinstallation of this product.•FAILURE TO FOLLOW THESE SAFETY PRECAUTIONS AND INSTRUCTIONS COULD RESULT IN DAMAGE TO THE PRODUCT OR VEHICLE AND/OR SERIOUS INJURY TO YOU AND YOUR PASSENGERS!CAUTIONLoud siren noise can cause hearing damage and/or loss.Refer to OSHA Section 1910.95prior to putting ANY siren into service!Wear Protection!ACTIVATION OF THIS SIREN MAY DAMAGE UNPROTECTED EARS!Warnings to InstallersWhelen’s emergency vehicle warning devices must be properly mounted and wired in order to be effective and safe. Read and follow all of Whelen’s written instructions when installing or using this device. Emergency vehicles are often operated under high speed stressful conditions which must be accounted for when installing all emergency warning devices. Controls should be placed within convenient reach of the operator so that they can operate the system without taking their eyes off the roadway. Emergency warning devices can require high electrical voltages and/or currents. Properly protect and use caution around live electrical connections.Grounding or shorting of electrical connections can cause high current arcing, which can cause personal injury and/or vehicle damage, including fire. Many electronic devices used in emergency vehicles can create or be affected by electromagnetic interference. Therefore, after installation of any electronic device it is necessary to test all electronic equipment simultaneously to insure that they operate free of interference from other components within the vehicle. Never power emergency warning equipment from the same circuit or share the same grounding circuit with radio communication equipment. All devices should be mounted in accordance with the manufacturer’s instructions and securely fastened to vehicle elements of sufficient strength to withstand the forces applied to the device. Driver and/or passenger air bags (SRS) will affect the way equipment should be mounted. This device should be mounted by permanent installation and within the zones specified by the vehicle manufacturer, if any. Any device mounted in the deployment area of an air bag will damage or reduce the effectiveness of the air bag and may damage or dislodge the device. Installer must be sure that this device, its mounting hardware and electrical supply wiring does not interfere with the air bag or the SRS wiring or sensors. Mounting the unit inside the vehicle by a method other than permanent installation is not recommended as unit may become dislodged during swerving; sudden braking or collision. Failure to follow instructions can result in personal injury. Whelen assumes no liability for any loss resulting from the use of this warning device. PROPER INSTALLATION COMBINED WITH OPERATOR TRAINING IN THE PROPER USE OF EMERGENCY WARNING DEVICES IS ESSENTIAL TO INSURE THE SAFETY OF EMERGENCY PERSONNEL AND THE PUBLIC.Warnings to UsersWhelen’s emergency vehicle warning devices are intended to alert other operators and pedestrians to the presence and operation of emergency vehicles and personnel. However, the use of this or any other Whelen emergency warning device does not guarantee that you will have the right-of-way or that other drivers and pedestrians will properly heed an emergency warning signal. Never assume you have the right-of-way. It is your responsibility to proceed safely before entering an intersection, driving against traffic, responding at a high rate of speed, or walking on or around traffic lanes. Emergency vehicle warning devices should be tested on a daily basis to ensure that they operate properly. When in actual use, the operator must ensure that both visual and audible warnings are not blocked by vehicle components (i.e.: open trunks or compartment doors), people, vehicles, or other obstructions. It is the user’s responsibility to understand and obey all laws regarding emergency warning devices. The user should be familiar with all applicable laws and regulations prior to the use of any emergency vehicle warning device. Whelen’s audible warning devices are designed to project sound in a forward direction away from the vehicle occupants. However, because sustained periodic exposure to loud sounds can cause hearing loss, all audible warning devices should be installed and operated in accordance with the standards established by the National Fire Protection Association.Safety FirstThis document provides all the necessary information to allow your Whelen product to be properly and safely installed. Before beginning the installation and/or operation of your new product, the installation technician and operator must read this manual completely. Important information is contained herein that could prevent serious injury or damage.WARNING: This product can expose you to chemicals including Lead which is known to the State of California to cause cancer and birth defects or other reproductive harm. For more information go to .Page 2Notes:1)TD/AUX =Takedown /Auxiliary Take-Downs or Worklights2)Some configurations will allow specific buttons to activate alternate functions with each press of that button. In the artwork shown,these buttons are represented with white letters on a black background. In these cases, the functions to be activated are shown in sequential order and are separated with a horizontal line.Dip Switch Configuration #1Dip Switch Configuration #2Dip Switch Configuration #3California Title13 compliantOn Off1ON23412,3,4On Off1ON23421,3,4On Off1ON2342,31,4On Off1ON23441,2,3On Off1ON2341,2,43On Off1ON2343,41,2On Off1ON2341,23,4On Off1ON2341,2,34On Off 1ON2341,42,3Pos.1 -T/A LeftPos.1 -T/A LeftPos.1 -T/A LeftPos.2 -T/A SplitPos.2 -T/A Split Pos.2 -T/A SplitPos.3 -T/A Right Pos.3 -T/A Right Pos.3 -T/A Right L Alley R AlleyLight Bar CruiseFront Cutoff Patrn Over-rideTD/AUXMode 1Front Cutoff Mode 2Low PowerPatrn Over-rideTD/AUXMode 1Low PowerFront CutoffMode 2Mode 3TD/AUXCruise TD/AUXTA RightL Alley R AlleyTA Left TA Split L Alley R AlleyTA Left TA Split Patrn Over-rideTD/AUXTA RightPatrn Over-rideTD/AUXOn Off1ON23431,2,4On Off1ON2341,32,4Dip Switch Configuration #4Dip Switch Configuration #7Dip Switch Configuration #10Pos.1 -All Bar 1Pos.1 -FrontPos.1 -FrontPos.1 -FrontPos.1 -FrontPos.1 -RearPos.1 -FrontPos.1 -All Bar 1Pos.1 -All Bar 1Pos.2 -All Bar 2Pos.2 -RearPos.2 -RearPos.2 -RearPos.2 -Rear Pos.2 -FrontPos.2 -RearPos.2 -All Bar 2Pos.2 -All Bar 2Pos.3 -All Bar 3Pos.3 -All Pos.3 -All Pos.3 -All Pos.3 -All Pos.3 -All Pos.3 -All Pos.3 -All Bar 3Pos.3 -All Bar 3Dip Switch Configuration #5Dip Switch Configuration #8Dip Switch Configuration #11Dip Switch Configuration #12Dip Switch Configuration #6Dip Switch Configuration #9TA Left TA SplitTD/AUXL Alley R AlleyLow Power Front CutoffRear Cutoff TA RightTA Left Low PowerFront CutoffTA Split TA RightTD/AUXL Alley R AlleyTA Left TA Split TD/AUXTA RightLow PowerL Alley R AlleyTA Left TA Split Front FlashTD/AUXTA RightTA Left TA SplitL Alley R AlleyPatrn Over-rideCruise TD/AUXTA RightOn Off1ON2342, 41, 3Front TA Left Rear TA RightFront TA RightLeft Alley Right AlleyRear TA Left Flash Alley TD Left Alley Right AlleyCruise Secure the mounting plate to the control head using the supplied 4 X 1/4 PFH Plasti-Loc screws.NOTE: Dip switches are located on the back of the unit.1.Secure the controller to the mounting surface using the supplied 6 X 1/2" PPHSMS.Extend the wires and connect as described below.Installation:2.3.WARNING!All customer supplied wires that connect to the positive terminal of the battery must be sized to supply at least 125%of the maximum operating current and at the battery to carry the load.DO NOT USE CIRCUIT BREAKERS WITH THIS PRODUCT!FUSED BLK RED WHTGRN GRYto +12VDC Fuse (3A)Fuse (1A)4-1/4 PFH Plasti-Loc Screw (qty. 4)Mounting Plate4-1/2 PPHSMS (qty. 2)to +12VDC ignition controlled circuit (Backlight)to Groundto WeCan® Lightbar。

美国朗迪安全闸门操作器说明书

美国朗迪安全闸门操作器说明书

ACCESS CONTROL SOLUTIONS• O perator is24 VoltDC and includes built-in battery backup• 115/230 VAC (switch selectable) or 24 VDC Solar Power• 1/2 HP Quadra Drive Heavy-duty DC Motor• A djustable limit nuts for precise gate limit control• Easy to use manual T-handle release • Heavy-duty gearbox• 0.0 Amp SBPD Circuit (solar power only)• Solar power ready • Pad or post mount • Heavy-duty steel frame • 5-year limited warrantyfull size gearboxhea vy-duty 30:1 r a tio gearboxeasy to use“T-Handle” releasequadra drive DC motorfor longer life9024 VEHICULARSLIDE GATEAC/DC OPERATORgate trackerreporting outputMechanicalFrame: 3/16 steel, corrosion protected Cover: 1/4 inch polyethyleneReduction: belt driven 30:1 gear reduction running in a continuous oil bathSpeed: Approximately 1 ft/sec (30.5 cm/sec)Chain: Unit is shipped with 20-ft of #40 roller chain Manual Release: “T-Handle” release is easily accessible from front of operatorOperator re-connects automatically when handle is releasedOptionsHeater kit for cold weather environments Can only be used with AC powered operators Steel base plate for post mounting 18 Ah batteries (AC powered operator only)Solar Kit (Includes two 18 Ah batteries and 10 Watt, 24 VDC solar panel)ElectricalAdjustable partial open limitEasy adjustable chain driven limit nuts Auto-close timer 1-30 secondsSelectable loop/reverse input function; stop or reverse Anti-tailgating feature helps to control un-authorized traffic Standard normally closed stop circuit DC Power Shut-Off switch Battery protection circuitPorts for plug-in open and reverse loop detectors – DKS detectors onlyGate Tracker reporting output provides operator data to access control system (DKS 1833, 1835, 1837 or 1838 only)AC Powered Operator Only 115 VAC Convenience outlets AC Power Shut-Off switch DC Powered Operator Only 0.0 Amp SBPD PatPend CircuitMiscellaneousEnvironmental: -10ºF to 140ºF (23°C to 62°C)Thermostatically controlled heater kit required for operation below freezing temperatures to preventbatteries from freezing. Heater kit can only be used with AC powered operators.Operator requires Type B1 or Type B2 entrapment protection devices with 10K resistive termination, otherwise the operator will not functionShipping weight approximately 130-150 Lbs (59-68 kg) Depending on model and options selectedTechnical FeaturesDistributed by:Access Control Solutions since 19481 A ssumes gate is on level ground, in good condition with properly adjusted hardware.2 A ssumes a 16 foot gate weighing 1000 Lbs. Other external factors (temperature, chargestate of batteries, gate weight, gate length, etc.) will affect the performance of the gate operator and may reduce the number of cycles shown.MEMBER:120 Glasgow Avenue, Inglewood, California 90301 U.S.A. Tel: 310-645-0023 FAX: 310-641-1586 © 2018 All Rights Reserved. Product specifications may change without notice. Rev. 4/18。

日业BM560X CM560系列起重专用变频器用户手册V2.0

日业BM560X CM560系列起重专用变频器用户手册V2.0
第七章 参数说明............................................................................................................................................................. 67
7.1 F0 组基本功能组.................................................................................................................................................. 67 7.2 F1 组启停控制...................................................................................................................................................... 72 7.3 F2 组 V/F 控制参数..............................................................................................................................................75 7.4 F3 组矢量控制参数.............................................................................................................................................. 77 7.5 F4 组电机参数...................................................................................................................................................... 79 7.6 F5 组输入端子...................................................................................................................................................... 80 7.7 F6 组输出端子...................................................................................................................................................... 85 7.8 F7 组 辅助功能及人机界面功能....................................................................................................................... 86 7.9 F8 组通信功能...................................................................................................................................................... 93 7.10 F9 组故障与保护................................................................................................................................................ 94 7.11 FA 组过程控制 PID 功能...................................................................................................................................96 7.12 FB 组摆频功能....................................................................................................................................................98 7.13 FC 组多段速功能及简易 PLC 功能................................................................................................................. 99 7.14 FD 组(保留)................................................................................................................................................. 103 7.15 FE 组 增强组....................................................................................................................................................104 7.15 FF 组 厂家参数组............................................................................................................................................104

动规-背包九讲完整版

动规-背包九讲完整版

背包问题九讲 v1.0目录第一讲 01背包问题第二讲完全背包问题第三讲多重背包问题第四讲混合三种背包问题第五讲二维费用的背包问题第六讲分组的背包问题第七讲有依赖的背包问题第八讲泛化物品第九讲背包问题问法的变化附:USACO中的背包问题前言本篇文章是我(dd_engi)正在进行中的一个雄心勃勃的写作计划的一部分,这个计划的内容是写作一份较为完善的NOIP难度的动态规划总结,名为《解动态规划题的基本思考方式》。

现在你看到的是这个写作计划最先发布的一部分。

背包问题是一个经典的动态规划模型。

它既简单形象容易理解,又在某种程度上能够揭示动态规划的本质,故不少教材都把它作为动态规划部分的第一道例题,我也将它放在我的写作计划的第一部分。

读本文最重要的是思考。

因为我的语言和写作方式向来不以易于理解为长,思路也偶有跳跃的地方,后面更有需要大量思考才能理解的比较抽象的内容。

更重要的是:不大量思考,绝对不可能学好动态规划这一信息学奥赛中最精致的部分。

你现在看到的是本文的1.0正式版。

我会长期维护这份文本,把大家的意见和建议融入其中,也会不断加入我在OI学习以及将来可能的ACM-ICPC的征程中得到的新的心得。

但目前本文还没有一个固定的发布页面,想了解本文是否有更新版本发布,可以在OIBH论坛中以“背包问题九讲”为关键字搜索贴子,每次比较重大的版本更新都会在这里发贴公布。

目录第一讲 01背包问题这是最基本的背包问题,每个物品最多只能放一次。

第二讲完全背包问题第二个基本的背包问题模型,每种物品可以放无限多次。

第三讲多重背包问题每种物品有一个固定的次数上限。

第四讲混合三种背包问题将前面三种简单的问题叠加成较复杂的问题。

第五讲二维费用的背包问题一个简单的常见扩展。

第六讲分组的背包问题一种题目类型,也是一个有用的模型。

后两节的基础。

第七讲有依赖的背包问题另一种给物品的选取加上限制的方法。

第八讲泛化物品我自己关于背包问题的思考成果,有一点抽象。

USACO习题总结

USACO习题总结
2.4.1 2.4.2 2.4.3 2.4.4 2.4.5
The Castle Ordered Fractions Sorting A Three-Valued Sequence Healthy Holsteins Hamming Codes
Preface Numbering Subset Sums Runaround Numbers Party Lamps
USACO 习 题 总 结
Chongqing Nankai High School
USACO 习题总结
前言
USACO 全 称 美国计算机奥林匹克竞赛,其官方网站所开设的训练 系统 USACO Training,是全球知名的信息学在线题库。该题库拥有很高 的题目质量,且难度由浅及深层次清晰,使得不同水平的竞赛选手均能从 中获益。本文即是笔者历时数月完成 USACO Training 中全部题目后所做 的习题总结,以供日后复习和参考之用。
附:参考资料 …………………………………… P31
-2-
USACO 习 题 总 结
一、题目索引
Chongqing Nankai High School
第一章
Chapter1 Getting started
1.1.1 1.1.2 1.1.3 1.1.4
1.2.1 1.2.2 1.2.3 1.2.4 1.2.5
二、简明题解
Chapter1 Getting started
Chongqing Nankai High School
1.1.1 题目 题型 题解
Your Ride Is Here (ride) 计算并比较两字符串每位字符 ASCII 值的连续乘积。 字符串处理 直接模拟即可。
1.1.2 题目 题型 题解

动规-背包九讲完整版

动规-背包九讲完整版
如果并没有要求必须把背包装满,而是只希望价格尽量大,初始化时应该将 f[0..V]全部设 为 0。
为什么呢?可以这样理解:初始化的 f 数组事实上就是在没有任何物品可以放入背包时的合 法状态。如果要求背包恰好装满,那么此时只有容量为 0 的背包可能被价值为 0 的 nothing“恰好装满”,其它容量的背包均没有合法的解,属于未定义的状态,它们的值就都 应该是-∞了。如果背包并非必须被装满,那么任何容量的背包都有一个合法解“什么都不 装”,这个解的价值为 0,所以初始时状态的值也就全部为 0 了。
前言
本篇文章是我(dd_engi)正在进行中的一个雄心勃勃的写作计划的一部分,这个计划的内容是 写作一份较为完善的 NOIP 难度的动态规划总结,名为《解动态规划题的基本思考方式》。现 在你看到的是这个写作计划最先发布的一部分。
背包问题是一个经典的动态规划模型。它既简单形象容易理解,又在某种程度上能够揭示动 态规划的本质,故不少教材都把它作为动态规划部分的第一道例题,我也将它放在我的写作 计划的第一部分。
这个小技巧完全可以推广到其它类型的背包问题,后面也就不再对进行状态转移之前的初始 化进行讲解。
小结
01 背包问题是最基本的背包问题,它包含了背包问题中设计状态、方程的最基本思想,另 外,别的类型的背包问题往往也可以转换成 01 背包问题求解。故一定要仔细体会上面基本思 路的得出方法,状态转移方程的意义,以及最后怎样优化的空间复杂度。
感谢 XiaQ,它针对本文的第一个 beta 版发表了用词严厉的六条建议,虽然我只认同并采纳 了其中的两条。在所有读者几乎一边倒的赞扬将我包围的当时,你的贴子是我的一剂清醒 剂,让我能清醒起来并用更严厉的眼光审视自己的作品。
当然,还有用各种方式对我表示鼓励和支持的几乎无法计数的同学。不管是当面赞扬,或是 在论坛上回复我的贴子,不管是发来热情洋溢的邮件,或是在即时聊天的窗口里竖起大拇 指,你们的鼓励和支持是支撑我的写作计划的强大动力,也鞭策着我不断提高自身水平,谢 谢你们!
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Wizard1.单调队列优化①土地并购(Land Acquisition,2008Mar)②干草塔(Tower of Hay,2009Open)③又买饲料(Buying Feed,2010Nov)④玉米实验(Cornfields,2003Mar)⑤修剪草坪(Mowing the Lawn,2011Open)2.树型①焊接(Soldering,2011Open)②产奶比赛(Milk Team Select,2006Mar)③道路重建(Rebuilding Roads,Feb2002)④手机网络(Cell Phone Network,2008Jan)3.背包问题续①电子游戏(Video Game Troubles,2009Dec)②最少找零(The Fewest Coins,2006Dec)③三个代表(Jersey Politics,2005Feb)④录制唱片(Raucous Rockers,1996Qualifying Round)4.背包问题①股票市场(Stock Market,2009Feb)②奶牛会展(Cow Exhibition,2003Fall)③太空电梯(Space Elevator,2005Mar)④平分子集(Subset Sums,1998Spring)5.区间型①提交作业(Turning in Homework,2004Open)②抢鲜草(Grazing on the Run,2005Nov)③最优回文(Cheapest Palindrome,2007Open)④智取金币(Treasure Chest,2010Dec)6.其他一①打扫食槽(Cleaning Up,2009Mar)②奶牛自行车队(Cow Cycling,Feb2002)③滑雪缆车(Ski Lift,2006Mar)④奶牛飞盘队(Cow Frisbee Team,2009Mar)7.其他二①滑雪比赛(Bobsledding,2009Dec)②滑雪课程(Ski Lessons,2009Open)③方形牛棚(Big Barn,1997Fall)④接住苹果(Apple Catching,2004Nov)⑤公司利润(Profits,2011Jan)土地并购(Land Acquisition,2008Mar)首先我们按长与宽都递减の排序,如果有一个矩形长宽都不如另一个矩形,那么可以忽略它。

剩下的矩形可以看做,长度递增而宽度递减。

F[i]表示前i个矩形的最小花费。

那么有f[i]=min(f[j]+x[j+1]*y[i])(j<i)当然O(N^2)的算法是对不完的。

斜率优化不再赘述。

干草塔(Tower of Hay,2009Open)显然,将塔看作一个面积一定图形,要使其最高,必须最瘦。

F[i]表示从n->i层的最底层的宽度。

F[i]=min(sum[j-1])-sum[i-1];(N>j>i)显然,j越小F[i]越优。

G[i]自然用来记n->i最多的层数。

当然F[i]>=F[j],即:F[j]<=min(sum[j-1])-sum[i-1]。

Sum[i-1]<=sum[j-1]-f[j],sum[i-1]是递减的,所以当第一个i满足条件后,之后的i-1~1都是满足的。

for(int i=n;i;--i){while(h<t&&f[q[h+1]]<=sum[q[h+1]-1]-sum[i-1])h++;//找出最后一个满足的f[i]=sum[q[h]-1]-sum[i-1];g[i]=g[q[h]]+1;q[++t]=i;//入队while((t>h)&&(f[q[t-1]]-sum[q[t-1]-1]+sum[q[t]-1]>f[q[t]]))--t,q[t]=q[t+1];}又买饲料(Buying Feed,2010Nov)F[i][j]表示到第i个商店时,一共买了j那么多饲料的最小花费。

F[i][j]=min{f[i-1][k]+(j-k)*v[i-1]}+j*j;(k<j&&(j-k<=c[i-1]))用单调队列优化:F[i][j]=min{f[i-1][k]-k*v[i-1]}+j*v[i-1]+j*j这样取最小值的循环里就只与k有关,此时维持一个f[i-1][k]-k*v[i-1]的递减单调序列,每次选择将为O(1)。

玉米实验(Cornfields,2003Mar)首先,我们可以使用RMQ来查询每排的最小值最大值,即初始化需要N个RMQ,O(N^2*log(N))是可以接受的。

之后的K次询问,每次询问B排的最值,O(N*K)可以AC。

修剪草坪(Mowing the Lawn,2011Open)f[i]表示i不要的最小舍弃值。

for(int i=0;i<=n+1;i++){if(q[s].n<i-k-1&&s<t)s++;//队列长超过k头指针+ f[i]=q[s].v+a[i];//队列开头的是最小的,因此舍弃它while(q[t].v>f[i]&&t>=s)t--;//维持一个递增序列q[++t]=Cut{f[i],i};//入队}Cout<<sum-f[n+1];焊接(Soldering,2011Open)产奶比赛(Milk Team Select,2006Mar)类似于道路重建,即f[x][i]表示节点x分配i个关系能够取得的最大奶量,由于可以是散点,所以可以将这i个关系随意分配给儿子们,最后取最好的方案。

关于如何去最佳方案,我们可以用背包分配。

道路重建(Rebuilding Roads,Feb2002)F[i][j]表示以第i个节点的子树要变为只有j个儿孙(自己也算)的树所需要剪得最少的边。

然后对儿子们进行背包分配,得出他们各留多少子孙,使花费最小。

手机网络(Cell Phone Network,2008Jan)相当于皇宫看守。

F[x][0]表示不在x上放但监控x的节点们(包括x自己)的最小费用;F[x][1]表示不在x上放但监控x的节点们(不一定包括x自己)的最小费用;F[x][2]表示在x上放且监控x的节点们的最小费用;则有:~~~~~~T必须由他的儿子监控~~~~~~T不一定由他的儿子监控~~~~~~T自己监控电子游戏(Video Game Troubles,2009Dec)即“金明的预算方案”加强版,每个游戏平台可带10个游戏,所以他们可以处理为2^10个不同的商品且分为一组。

那么可以分为k组,每组有1024个游戏,每组选1个或0个。

之后即为分组背包。

最少找零(The Fewest Coins,2006Dec)直接将土豪的补钱视作面值为’-’的纸币,并且有无限张。

那么可以当做“有限硬币问题”解决,即取得面值x所需要的最少硬币数。

三个代表(Jersey Politics,2005Feb)类似于三角形牧场,我们只关心两个选区的Jersey牛是否能够超过半数。

使用01背包拓展f[i][j]成立的情况,最后检查是否有i,j都超过500的成立。

不过貌似方案要另找,且数据大了要爆。

录制唱片(RaucousRockers,1996QualifyingRound)f[i][j][k]表示在前i张唱片、录到第j分钟、录到第k 首歌所录得最多歌曲数。

f[i][j][k]=max{前一分钟的歌曲数,前一首歌的歌曲数,把第k首歌在当前位置放进去的歌曲数(如果可以)}。

for(i=1;i<=m;i++)//第i张唱片for(j=1;j<=t;j++)//第j分钟for(k=1;k<=n;k++){//第k首歌if(j==1)//换唱片f[i][j][k]=max(f[i-1][t][k],f[i][j][k-1]);//前一首歌的歌曲数//前一分钟的歌曲数(下同)else//没有换唱片f[i][j][k]=max(f[i][j][k-1],f[i][j-1][k]);if(len[k]<j)//没有换唱片f[i][j][k]=max(f[i][j][k],f[i][j-len[k]][k-1]+1);//把第k首歌在当前位置放进去的歌曲数(下同)if(len[k]==j)//换唱片f[i][j][k]=max(f[i][j][k],f[i-1][t][k-1]+1);}股票市场(Stock Market,2009Feb)显然f[i]表示第i天所能拥有的最大钱数。

我们第i天赚得越多,f[i+1]就会越大。

但是我们不能用所有钱去买某只赚得最多的股票,因为那样可能剩下一些零钱,或是直接买次一等的但更多的反而更好。

那怎么分配呢?将v[i+1]-v[i]视做价值,我们发现每天做一次01背包即可。

奶牛会展(Cow Exhibition,2003Fall)二维01背包,因为背包只能解决正数的问题,所以我们整体偏移1000,那么以1000为0点,在f[1000][1000]之后寻找答案,使i+j最大即可。

太空电梯(Space Elevator,2005Mar)首先按安全高度排序,因为安全高度小的要想被利用,只能呆在最下面。

之后依次添加,只要在安全高度以内,有多少价多少。

平分子集(Subset Sums,1998Spring)for(int i=1;i<=N;i++)for(int j=N*(N+1)/4;j>=i;j--)//01背包dp[j]+=dp[j-i];cout<<dp[N*(N+1)/4]/2;//二分之总数的情况除以2是因为两部分对称提交作业(Turning in Homework,2004Open)由大区间推出小区间。

F[i][j][0]表示在整个i~j区间里只有i这个作业交了;F[i][j][1]表示在整个i~j区间里只有j这个作业交了;初始化:dp[1][n][0]=max(a[1].x,a[1].t)在1-n区间内只交了1作业dp[1][n][1]=max(a[n].x,a[n].t)在1-n区间内只交了n作业状态转移方程:dp[i][j][0]=min(max(dp[i-1][j][0]+x[i]-x[i-1],t[i],max(dp[i][j+1][1]+x[j+1]-x[i],t[i])) dp[i][j][1]=min(max(dp[i][j+1][1]+x[j+1]-x[j],t[j]),max(dp[i-1][j][0]+x[j]-x[i-1],t[j]))抢鲜草(Turning in Homework,2004Open)奶牛逃跑型dp.f[i][j][1]表示吃完i~j后停在i的最小损失,f[i][j][0]表示吃完i~j后停在j的最小损失。

相关文档
最新文档