操作间没有次序关系,同一个操作最多重复3次。。。

可以直接暴力。。。

The Clocks
IOI'94 - Day 2

Consider nine clocks arranged in a 3x3 array thusly:

|-------|    |-------|    |-------|
| | | | | | |
|---O | |---O | | O |
| | | | | |
|-------| |-------| |-------|
A B C |-------| |-------| |-------|
| | | | | |
| O | | O | | O |
| | | | | | | | |
|-------| |-------| |-------|
D E F |-------| |-------| |-------|
| | | | | |
| O | | O---| | O |
| | | | | | | |
|-------| |-------| |-------|
G H I

The goal is to find a minimal sequence of moves to return all the dials to 12 o'clock. Nine different ways to turn the dials on the clocks are supplied via a table below; each way is called a move. Select for each move a number 1 through 9 which will cause the dials of the affected clocks (see next table) to be turned 90 degrees clockwise.

Move Affected clocks
1 ABDE
2 ABC
3 BCEF
4 ADG
5 BDEFH
6 CFI
7 DEGH
8 GHI
9 EFHI

Example

Each number represents a time according to following table:

9 9 12       9 12 12       9 12 12        12 12 12      12 12 12
6 6 6 5 -> 9 9 9 8-> 9 9 9 4 -> 12 9 9 9-> 12 12 12
6 3 6 6 6 6 9 9 9 12 9 9 12 12 12

[But this might or might not be the `correct' answer; see below.]

PROGRAM NAME: clocks

INPUT FORMAT

Lines 1-3: Three lines of three space-separated numbers; each number represents the start time of one clock, 3, 6, 9, or 12. The ordering of the numbers corresponds to the first example above.

SAMPLE INPUT (file clocks.in)

9 9 12
6 6 6
6 3 6

OUTPUT FORMAT

A single line that contains a space separated list of the shortest sequence of moves (designated by numbers) which returns all the clocks to 12:00. If there is more than one solution, print the one which gives the lowest number when the moves are concatenated (e.g., 5 2 4 6 < 9 3 1 1).

SAMPLE OUTPUT (file clocks.out)

4 5 8 9

Submission file Name:

USACO Gateway |   
Comment or Question

/*
ID:qhn9992
PROG:clocks
LANG:C++11
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; int a[10],c[10];
int b[10][10]
={ 0,0,0,0,0,0,0,0,0,0,
1,1,0,1,1,0,0,0,0,0,
1,1,1,0,0,0,0,0,0,0,
0,1,1,0,1,1,0,0,0,0,
1,0,0,1,0,0,1,0,0,0,
0,1,0,1,1,1,0,1,0,0,
0,0,1,0,0,1,0,0,1,0,
0,0,0,1,1,0,1,1,0,0,
0,0,0,0,0,0,1,1,1,0,
0,0,0,0,1,1,0,1,1,0
}; int main()
{
freopen("clocks.in","r",stdin);
freopen("clocks.out","w",stdout);
int cnt=0; for(int i=1;i<=9;i++)
{
scanf("%d",a+i);
a[i]=(a[i]/3)%4;
}
for(c[1]=0;c[1]<4;c[1]++)
{
for(c[2]=0;c[2]<4;c[2]++)
{
for(c[3]=0;c[3]<4;c[3]++)
{
for(c[4]=0;c[4]<4;c[4]++)
{
for(c[5]=0;c[5]<4;c[5]++)
{
for(c[6]=0;c[6]<4;c[6]++)
{
for(c[7]=0;c[7]<4;c[7]++)
{
for(c[8]=0;c[8]<4;c[8]++)
{
for(c[9]=0;c[9]<4;c[9]++)
{
///check....
bool flag=true;
for(int i=1;i<=9;i++)
{
int t=a[i];
for(int j=1;j<=9;j++)
{
t+=b[j][i-1]*c[j];
}
t=t%4;
if(t)
{
flag=false;
break;
}
}
if(flag)
{
for(int i=1;i<=9;i++)
{
while(c[i]--)
{
if(flag)
{
flag=false;
}
else putchar(32);
printf("%d",i);
}
}
putchar(10);
return 0;
}
else continue;
}
}
}
}
}
}
}
}
}
return 0;
}

USACO The Clocks的更多相关文章

  1. 【USACO】clocks 遇到各种问题 最后还是参考别人的思路

    //放在USACO上一直通不过 不知道哪里出了问题 输出的n总是等于1 但是BFS递归的次数是对的 <----这个问题解决了 局部变量压入queue中返回就是对的了 #include<io ...

  2. USACO 6.5 The Clocks

    The ClocksIOI'94 - Day 2 Consider nine clocks arranged in a 3x3 array thusly: |-------| |-------| |- ...

  3. USACO chapter1

    几天时间就把USACO chapter1重新做了一遍,发现了自己以前许多的不足.蒽,现在的程序明显比以前干净很多,而且效率也提高了许多.继续努力吧,好好的提高自己.这一章主要还是基本功的训练,没多少的 ...

  4. USACO 完结的一些感想

    其实日期没有那么近啦……只是我偶尔还点进去造成的,导致我没有每一章刷完的纪念日了 但是全刷完是今天啦 讲真,题很锻炼思维能力,USACO保持着一贯猎奇的题目描述,以及尽量不用高级算法就完成的题解……例 ...

  5. USACO . Your Ride Is Here

    Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often co ...

  6. 【USACO 3.1】Stamps (完全背包)

    题意:给你n种价值不同的邮票,最大的不超过10000元,一次最多贴k张,求1到多少都能被表示出来?n≤50,k≤200. 题解:dp[i]表示i元最少可以用几张邮票表示,那么对于价值a的邮票,可以推出 ...

  7. USACO翻译:USACO 2013 NOV Silver三题

    USACO 2013 NOV SILVER 一.题目概览 中文题目名称 未有的奶牛 拥挤的奶牛 弹簧牛 英文题目名称 nocow crowded pogocow 可执行文件名 nocow crowde ...

  8. USACO翻译:USACO 2013 DEC Silver三题

    USACO 2013 DEC SILVER 一.题目概览 中文题目名称 挤奶调度 农场航线 贝西洗牌 英文题目名称 msched vacation shuffle 可执行文件名 msched vaca ...

  9. USACO翻译:USACO 2014 DEC Silver三题

    USACO 2014 DEC SILVER 一.题目概览 中文题目名称 回程 马拉松 奶牛慢跑 英文题目名称 piggyback marathon cowjog 可执行文件名 piggyback ma ...

随机推荐

  1. oracle for update和for update nowait的区别 - 转

    1.for update 和 for update nowait 的区别: 首先一点,如果只是select 的话,Oracle是不会加任何锁的,也就是Oracle对 select 读到的数据不会有任何 ...

  2. javapms部署之后首页不能正常显示问题

    今天在ligerui的技术群里看见了javapms,于是就到官网逛了逛 首先要做的就是了解了javapms使用到的技术 然后下载了程序安装包javapms_v1.1_beta(官网下载失败了,就bai ...

  3. Intellij 2016非服务器激活

    下载 http://idea.lanyus.com/jar/JetbrainsCrack-2.6.2.jar 并将 JetbrainsCrack-2.6.0.jar 放置到 D盘根目录(也可以根据自己 ...

  4. 最近输入法的问题:关于ctrl + space 无法开关闭输入法的问题

    输入法无法切换最好解决方法首先任务栏上的输入法图标上点右键选择设置. 然后选择键设置,双击第一个“在不同的输入语言之间切换”先勾选“切换输入语言”下面选择左手ALT.取消右边“切换键盘布局”前的勾. ...

  5. YII2 搭建redis拓展(教程)

    安装redis扩展: 1.通过composer进行安装,到项目根目录cmd运行(推荐) php composer.phar require --prefer-dist yiisoft/yii2-red ...

  6. POI-PPT官方文档

    注意 请注意,XSLF仍然处于早期开发阶段,并且将来会在发行版中发生不兼容的更改. 特征索引 创建新的演示文稿 阅读现有演示文稿 使用预定义的布局创建幻灯片 删除幻灯片 重新订购幻灯片 更改幻灯片大小 ...

  7. hibernate validate

    http://docs.jboss.org/hibernate/validator/4.2/reference/zh-CN/html_single/  --hibernate validate htt ...

  8. Maven 与 IntelliJ IDEA 的完美结合

    你是否正在学习Maven?是否因为Maven难用而又不得不用而苦恼?是否对Eclipse于Maven的冲突而困惑? 那么我告诉你一个更直接更简单的解决方案: IntelliJ IDEA! 1. 什么是 ...

  9. electron demo项目npm install安装失败解决办法

    electron官网提供的demo项目,在npm install 的时候总是报错显示安装失败, 解决办法:FQ即可成功安装.

  10. 织梦Dedecms系统可疑文件include/filter.inc.php扫描出漏洞,该如何解决?

    今天在做网站监察的时候,发现网站出了一个问题,在对网站做木马监测的时候,扫描出一个可疑文件:/include/filter.inc.php,建议删除,但仔细检查后,发现此文件是织梦(Dedecms)系 ...