全国站

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

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

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

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

华中地区 | 河南 湖北 湖南

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

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

华南地区 | 广东 广西 海南

资    源
  • 资    源
当前位置:查字典高考网>高中频道>信息学联赛知识>信息学联赛知识: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】相关文章:

2007年全国高中数学联赛江西省预赛试卷

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

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

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

“读、思、问”三者结合是攻克高中语文的最佳工具

高考面试明日始 考生需带准考证和成绩单

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

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

全国高中数学联合竞赛简介

课改与高考脱节 素质教育校园很难真正践行

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

网友关注

语文的基础知识和语言运用答题套路

不分文理后的“高考题”惊呆网友:幸亏毕业早

清华常务副校长程建平任北师大党委书记

必知10组易混淆的大学专业(一)

2017高考:志愿填报的六大问题

解读:土木工程专业

2017年高考备考:高考作文不跑题的秘诀

徐州空军学院1个学科入选“十三五”江苏省重点学科

中共江苏省委党校3个学科入选“十三五”省重点学科

2017高考数学最"省时省力"的抢分技巧

2017内蒙古高考:群众举报违规报名行为奖励千元

解放军南京政治学院5个学科入选“十三五”省重点学科

2017语文复习:语文学科的特点三大方面

解放军国际关系学院4个学科入选“十三五”省重点学科

三本大学和专科院校区别在哪?

2016基础教育发展报告显示:高考报名人数触底

教你两招 轻松拿下英语单词

如何保证自己不被刷掉?

2017高考作文:十大热门话题考题预测

2017高考语文一轮专题复习:古代诗歌鉴赏

山东高考大变革 2017年正式实施

2017年度海军招飞政治考核信息网上填报指南

2016年高三重大事件规划时间表

2017年湖北高考艺术类统考允许考生兼报

2017年高考作文题目预测:细节决定成败

华侨子女高考无需“跨国奔波” 网上能办身份证明

盘点关注最多的十大专业,人气为什么那么高?

2017年高考网上预报名于12月6日截止

南京陆军指挥学院1个学科入选“十三五”省重点学科

解放军理工大学11个学科入选“十三五”江苏省重点学科

网友关注视频

沈阳音乐学院郎亦农教授的女高音高考曲目解析课程 第9集 《赛吾里麦》演唱讲解,音乐表现一定要自然流畅

最新高考数学全国2第12题视频讲解及答案

高考帮:招办面对面 第55集 上海视觉艺术学院

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

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

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

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

看懂图片,你也会做高考地理题,解析2019年高考文综地理4

这!就是专业 第36集 河北经贸大学——数学专业

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

高考同学看过来,难度系数三颗星的奥数1

高考体育四项生的日常训练——深蹲移动跳:发展膝关节,踝关节力量。

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

学渣儿子高考,英语选择题全选B!老师通报成绩的那一刻父亲懵了

2019高考语文试卷解析

知道班里的高考成绩后,山东班主任气吐血了

招办面对面 第76集 阜阳师范学院信息工程学院

高考英语作文分析2

2019高考数学全国2卷理科第16题视频讲解及答案

2019年高考试卷解析,数学套路不好用了

2019全国高考志愿填报攻略 第50集 天津市高考历史三年本科录取排名

探秘历史 第二季 第233集 考英语用来睡觉,结果仍是高考状元,如今她怎么样了?

高考阅卷名师给考生的高考作文密训课 第3集 高考作文审题实操方法精讲(一)

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

外国数学老师挑战中国高考题,一顿“凶猛操作”下来,被虐惨!

老师好:这大概是高考前所有班主任都会干的事,取消一切副课!

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

探秘历史 第二季 第211集 此人高考数学考了0分,因作文写3句话被重点大学录取

探秘历史 第二季 第479集 河南叛逆高考生,写下8000字批判作文,现状如何?

这!就是专业 第31集 阜阳师范学院信息工程学院