全国站

热门城市 | 全国 北京 上海 广东

华北地区 | 北京 天津 河北 山西 内蒙古

东北地区 | 辽宁 吉林 黑龙江

华东地区 | 上海 江苏 浙江 安徽 福建 江西 山东

华中地区 | 河南 湖北 湖南

西南地区 | 重庆 四川 贵州 云南 西藏

西北地区 | 陕西 甘肃 青海 宁夏 新疆

华南地区 | 广东 广西 海南

资    源
  • 资    源
当前位置:查字典高考网>高中频道>信息学联赛知识>信息学联赛知识:Complete Search

信息学联赛知识:Complete Search

来自:查字典高考网 2009-11-12

Complete Search

The Idea

Solving a problem using complete search is based on the ``Keep It Simple, Stupid'' principle. The goal of solving contest problems is to write programs that work in the time allowed, whether or not there is a faster algorithm.

Complete search exploits the brute force, straight-forward, try-them-all method of finding the answer. This method should almost always be the first algorithm/solution you consider. If this works within time and space constraints, then do it: it's easy to code and usually easy to debug. This means you'll have more time to work on all the hard problems, where brute force doesn't work quickly enough.

In the case of a problem with only fewer than a couple million possibilities, iterate through each one of them, and see if the answer works.

Careful, Careful

Sometimes, it's not obvious that you use this methodology.

Problem: Party Lamps [IOI 98]

You are given N lamps and four switches. The first switch toggles all lamps, the second the even lamps, the third the odd lamps, and last switch toggles lamps 1, 4, 7, 10, ... .

Given the number of lamps, N, the number of button presses made (up to 10,000), and the state of some of the lamps (e.g., lamp 7 is off), output all the possible states the lamps could be in.

Naively, for each button press, you have to try 4 possibilities, for a total of 410000 (about 106020 ), which means there's no way you could do complete search (this particular algorithm would exploit recursion).

Noticing that the order of the button presses does not matter gets this number down to about 100004 (about 1016 ), still too big to completely search (but certainly closer by a factor of over 106000 ).

However, pressing a button twice is the same as pressing the button no times, so all you really have to check is pressing each button either 0 or 1 times. That's only 24 = 16 possibilities, surely a number of iterations solvable within the time limit.

Problem 3: The Clocks [IOI 94]

A group of nine clocks inhabits a 3 x 3 grid; each is set to 12:00, 3:00, 6:00, or 9:00. Your goal is to manipulate them all to read 12:00. Unfortunately, the only way you can manipulate the clocks is by one of nine different types of move, each one of which rotates a certain subset of the clocks 90 degrees clockwise.

Find the shortest sequence of moves which returns all the clocks to 12:00.

The ``obvious'' thing to do is a recursive solution, which checks to see if there is a solution of 1 move, 2 moves, etc. until it finds a solution. This would take 9k time, where k is the number of moves. Since k might be fairly large, this is not going to run with reasonable time constraints.

Note that the order of the moves does not matter. This reduces the time down to k9 , which isn't enough of an improvement.

However, since doing each move 4 times is the same as doing it no times, you know that no move will be done more than 3 times. Thus, there are only 49 possibilities, which is only 262,072, which, given the rule of thumb for run-time of more than 10,000,000 operations in a second, should work in time. The brute-force solution, given this insight, is perfectly adequate.

Sample Problems

Milking Cows [USACO 1996 Competition Round]

Given a cow milking schedule (Farmer A milks from time 300 to time 1000, Farmer B from 700 to 1200, etc.), calculate

The longest time interval in which at least one cow was being milked

The longest time interval in which no cow is being milked

Perfect Cows Perfect Cow Cousins [USACO 1995 Final Round]

A perfect number is one in which the sum of the proper divisors add up to the number. For example, 28 = 1 + 2 + 4 + 7 + 14. A perfect pair is a pair of numbers such that the sum of the proper divisor of each one adds up to the other. There are, of course, longer perfect sets, such that the sum of the divisors of the first add up to the second, the second's divisors to the third, etc., until the sum of the last's proper divisors add up to the first number.

Each cow in Farmer John's ranch is assigned a serial number. from 1 to 32000. A perfect cow is one which has a perfect number as its serial. A group of cows is a set of perfect cow cousins if their serial numbers form a perfect set. Find all perfect cows and perfect cow cousins.

retrieved from http://ace.delos.com/usacogate

【信息学联赛知识:Complete Search】相关文章:

奥林匹克数学的技巧中篇(一)

高中数学竞赛基本知识集锦(四)

信息学联赛知识:基本程序题集解题报告

信息学联赛知识:动态规划的状态表示(一)

86所北京高校2007年具备高招资格

2005年全国高中数学联赛考点诠释(一)

高中数学联赛培训讲义(一)

信息学联赛知识:动态规划的状态表示(二)

九成人赞同高考改革 近六成人认为需要动大手术

高中数学竞赛基本知识集锦(二)

[标签:竞赛联赛,数学联赛]

网友关注

各地高考陆续改革 “新高考”会带来哪些新变化?

我国儿科医生缺口逾20万人 儿科人才“一将难求”

三位大学校长“论剑”双一流

工业和信息化部直属高校2017年本科新增备案专业名单

清华大学毕业生留京数量下降 连续4年低于50%

“电竞专业”集中涌现是实火还是虚热?

江苏小高考结束 学生笑称使出“洪荒之力”

2017起河南高校体美音3类专业报名随高考进行

研究生身体不适找“神医” 3.5万喝3杯矿泉水

2017年厦门大学自主招生简章

语文老师担忧年轻人阅读现状:态度是功利的

东大自主招生:今年拟恢复高考后综合评价录取

“双一流”建设引高校争抢人才 有人跳一圈待遇翻番

北林大2017年自主招生工作 计划招170个

上海浙江公布“新高考”方案 试点举措可能被复制到全国

“95后”大学生校园养鸡创业 年营业额达80万

湖北:今年体育高考将首次实行虹膜识别 防止考生替考

2017甘肃高考4月14日举行英语听力测试

2017高考备考:如何避免印象不深记忆淡化的问题

“双一流”是如何推进的?一图详解

补习成部分家长走不出的“囚徒困境”

专家解析孩子数学成绩上不去的原因

这些低调内涵又前途无量的高校你值得拥有!

高考信息“刷脸”查询

高考志愿早准备:如何根据模考成绩排名定位

能上这些大学强势专业, 不上985又何妨?

高考倒数77天,如何恶补物理?

国家民族事务委员会直属高校2017年本科新增备案专业名单

“艺考”像流水线“生产”艺术生有意义吗?

北京语言大学2017年自主招生简章

网友关注视频

2019高考·语文试题有亮点 凸显时代主题 厚植家国情怀

爆笑班主任 第一季 第220集 高考前最后一只视频,山东王老师揭秘高考的秘密

如何制作100万层的酥皮糕点?推算过程像数学高考题

高考英语作文分析2

凤凰县高级中学高考试卷分析专题教研会

老外:外国理科高材生遇到中国数学高考,看到题目狂喊:NO!

高级中学高考试卷分析专题教研评比活动

amc传媒音乐影像 第一季 第600集 高中校长演唱《记忆花园》为高考学子助力打气

招办面对面 第2集 中国科学技术大学

2019年高考数学全国2卷理科第4题讲解及答案

1000张学生用草稿纸考研专用免邮空白便宜薄演草演算纸白纸本书写纸批发打草a4大张实惠装18k高考数学草稿本

这!就是专业 第47集 江苏理工学院

高级中学高考试卷分析专题教研会

高中语文知识清单高考语文总複习工具书第5次修订五全綵版五三曲一线科学备考基础知识手册知识大集结资料书参考书导书高一高二高三

老马讲高考真题第九季2018年高考地理新课标一卷第37题

创艺第二届:2019届高考录取表彰大会暨“核桃音乐节”合影——你只管努力,剩下的交给创艺

高考政治一轮:《经济生活》第九课(社会主义市场经济)练习

乾坤已定,组合解读2019高考数学全国3卷理科18题,你是黑马吗?

武汉美术高考

这!就是专业 第20集 长沙理工大学—数据科学专业

NBA流言收割机 第6集 神预测?高考数学试题暗示猛龙勇士4

沈阳音乐学院郎亦农教授的女高音高考曲目解析课程 第1集 沈阳音乐学院郎亦农为你讲解女高音高考曲目

高中信息技术

视频|2019全国高考今日开考: 语文特级教师评析上海卷高考作文

体育大杂烩 第2217集 太厉害!马龙登上全国高考作文题

2019高考数学第四题技巧秒出答案

你高考成绩高吗?这道题目怎能成立?高难度奥数,能不能把你难住

凤凰县高级中学高考试卷分析专题教研会

这!就是专业 第43集 河北经贸大学—计算机科学与技术专业

高级中学高考试卷分析专题教研评比活动