POJ 1166 The Clocks
来源:互联网 发布:php留言板源代码 编辑:程序博客网 时间:2024/06/05 23:42
The Clocks
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9161 Accepted: 3564
Description
|-------| |-------| |-------|
| | | | | | |
|---O | |---O | | O |
| | | | | |
|-------| |-------| |-------|
A B C
|-------| |-------| |-------|
| | | | | |
| O | | O | | O |
| | | | | | | | |
|-------| |-------| |-------|
D E F
|-------| |-------| |-------|
| | | | | |
| O | | O---| | O |
| | | | | | | |
|-------| |-------| |-------|
G H I
(Figure 1)
There are nine clocks in a 3*3 array (figure 1). The goal is to return all the dials to 12 o'clock with as few moves as possible. There are nine different allowed ways to turn the dials on the clocks. Each such way is called a move. Select for each move a number 1 to 9. That number will turn the dials 90' (degrees) clockwise on those clocks which are affected according to figure 2 below.
Move Affected clocks
1 ABDE
2 ABC
3 BCEF
4 ADG
5 BDEFH
6 CFI
7 DEGH
8 GHI
9 EFHI
(Figure 2)
Input
Your program is to read from standard input. Nine numbers give the start positions of the dials. 0=12 o'clock, 1=3 o'clock, 2=6 o'clock, 3=9 o'clock.
Output
Your program is to write to standard output. Output a shortest sorted sequence of moves (numbers), which returns all the dials to 12 o'clock. You are convinced that the answer is unique.
Sample Input
3 3 02 2 22 1 2
Sample Output
4 5 8 9
Source
IOI 1994
题目大意:已知九个钟分别指向3 6 9 12 有九种操作 分别可以把几个钟顺时针转90° 问最少的把其都变成12点的步骤
题目分析:BFS 写了半天写迷糊了。。。 其实就是没种操作最多3次嘛 干脆9个循环!!!
代码如下:
- POJ 1166 The clocks
- POJ 1166 The Clocks
- POJ 1166 The Clocks
- POJ 1166 The Clocks
- poj 1166 The Clocks
- POJ 1166 The Clocks
- poj 1166 The Clocks
- poj 1166 The Clocks
- poj 1166 The Clocks
- poj The Clocks 1166
- POJ 1166 The Clocks
- POJ 1166:The Clocks
- POJ 1166 The Clocks
- POJ The Clocks 1166
- POJ 1166 The Clocks 笔记
- Poj-1166-The Clocks-枚举
- POJ 1166 The Clocks(暴力搜索)
- poj 1166 The Clocks 暴力枚举
- 《高效能人士的七个好习惯》读书笔记
- graphics.drawRect()坐标解释
- 缩略图宽度不同,设置其x坐标
- 查询数组中第一个大于给定数的元素的索引号
- perl 获取匹配行后面的多行
- POJ 1166 The Clocks
- shell /bin/bash^M: bad interpreter错误解决
- 载入图片后按指定宽高缩放比例
- 删除与原数组中相同的元素
- window下改oracle_sid
- javascript 日期格式化
- eaccelerator-0.9.6.1 在window下的编译安装
- 帮陈云庆做的手机主题翻页查询
- Iframe自适应高度