- 1、本文档共45页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
A decorative fence
问题求解与程序设计
李文新
Problem
A decorative fence
Table of Contents
The problem
Solution
The problem
CENTRAL EUROPEAN OLYMPIAD IN INFORMATICS
30 June – 6 July 2002
Day 1: fence
A decorative fence
Time limit: 1 s
Memory limit: 1 MB
The problem
Richard just finished building his new house. Now the only thing the house misses is a cute little wooden fence. He had no idea how to make a wooden fence, so he decided to order one.
The problem
Somehow he got his hands on the
ACME1 Fence Catalogue 2002, the
ultimate resource on cute little wooden
fences. After reading its preface he
already knew, what makes a little
wooden fence cute.
The problem
A wooden fence consists of N wooden planks, placed vertically in a row next to each other. A fence looks cute if and only if the following conditions are met:
The problem
? The planks have different lengths, namely 1, 2, . . . , N plank length units.
? Each plank with two neighbors is either larger than each of its neighbors or smaller
than each of them. (Note that this makes the top of the fence alternately rise and
fall.)
The problem
It follows, that we may uniquely
describe each cute fence with N planks
as a permutation a1, . . . , aN of the
numbers 1, . . . ,N such that (?i; 1 i
N) (ai - ai-1) * (ai - ai+1) 0 and vice
versa, each such permutation
describes a cute fence.
The problem
It is obvious, that there are many
different cute wooden fences made of
N planks.
The problem
To bring some order into their
catalogue, the sales manager of ACME
decided to order them in the following
way: Fence A (represented by the
permutation a1, . . . , aN) is in the
catalogue before fence B (represented
by b1, . . . , bN) if and only if there exists
such i, that
The problem
(?j i) aj = bj and (ai bi). (Also to
decide, which of the two fences is
earlier in the catalogue, take their
corresponding permutations, find the
first place on which they differ and
compare the values on this place.)
The problem
All the cute fences with N planks are
numbered (
您可能关注的文档
- 2016年5月宁波北仑区凤凰山主体乐园商业调查报告.pdf
- 2016年9月高考听力真题PETS2.doc
- 2016卓越寒假练习册、广州寒假作业(四年级).pdf
- 2016 ChinaJoy:杰拉网咖带你玩转泛娱乐时代.doc
- 2016年SAT阅读考试必读的书目清单推荐.pdf
- 2016年伦敦大学玛丽皇后学院研究生申请要求及排名解读.pdf
- 2016年农村东北大学单招模拟题(含解析).docx
- 2016年北京师范大学MTI翻译硕士考研历年真题解析,考研参考书,考研经验,考研报录比.pdf
- 2016年北京培黎职业学院自主招生模拟题(含解析).docx
- 2016年北京电影学院录音系电影声音创作方向在职艺术硕士考研复试辅导资料.pdf
文档评论(0)