- 浏览: 37157 次
- 性别:
- 来自: 湖南
最新评论
-
kulinglei:
提烟而过 写道问下楼主:你是拿了别人的注册号在这里害别人,还是 ...
折半搜索 -
jy00105276:
没看代码,看描述难道是2分法?
是的话不一定是a[i-1] ...
折半搜索 -
提烟而过:
问下楼主:你是拿了别人的注册号在这里害别人,还是没事在这里装- ...
折半搜索 -
zqynux:
fffvvvzz 写道11-15
是
11 12 13 14 ...
折半搜索 -
zqynux:
额,, 就是一个NOIP题目的答案..
vijos 谁拿了最多奖学金
The Tamworth Two
BIO '98 - Richard Forster
A pair of cows is loose somewhere in the forest. Farmer John is lending his expertise to their capture. Your task is to model their behavior.
The chase takes place on a 10 by 10 planar grid. Squares can be empty or they can contain:
an obstacle,
the cows (who always travel together), or
Farmer John.
The cows and Farmer John can occupy the same square (when they `meet') but neither the cows nor Farmer John can share a square with an obstacle. Each square is
represented
as follows:
. Empty square
* Obstacle
C Cows
F Farmer
Here is a sample grid:
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......
The cows wander around the grid in a fixed way. Each minute, they either move forward or rotate. Normally, they move one square in the direction they are facing. If there is an obstacle in the way or they would leave the board by walking `forward', then they spend the entire minute rotating 90 degrees clockwise.
Farmer John, wise in the ways of cows, moves in exactly the same way.
The farmer and the cows can be considered to move simultaneously during each minute. If the farmer and the cows pass each other while moving, they are not considered to have met. The chase ends when Farmer John and the cows occupy the same square at the end of a minute.
Read a ten-line grid that represents the initial state of the cows, Farmer John, and obstacles. Each of the ten lines contains exactly ten characters using the coding above. There is guaranteed to be only one farmer and one pair of cows. The cows and Farmer John will not initially be on the same square.
Calculate the number of minutes until the cows and Farmer John meet. Assume both the cows and farmer begin the simulation facing in the `north' direction. Print 0 if they will never meet.
PROGRAM NAME: ttwo
INPUT FORMAT
Lines 1-10: Ten lines of ten characters each, as explained above
SAMPLE INPUT (file ttwo.in)
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......
OUTPUT FORMAT
A single line with the integer number of minutes until Farmer John and the cows meet. Print 0 if they will never meet.
SAMPLE OUTPUT (file ttwo.out)
49
题目描述
两只牛逃跑到了森林里。农夫John开始用他的专家技术追捕这两头牛。你的任务是模拟他们的行为(牛和John)。
追击在10x10的平面网格内进行。一个格子可以是:
一个障碍物, 两头牛(它们总在一起), 或者 农民John. 两头牛和农民John可以在同一个格子内(当他们相遇时),但是他们都不能进入有障碍的格子。
一个格子可以是:
. 空地
* 障碍物
C 两头牛
F 农民John
这里有一个地图的例子:
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......
牛在地图里以固定的方式游荡。每分钟,它们可以向前移动或是转弯。如果前方无障碍且不会离开地图,它们会按照原来的方向前进一步。否则它们会用这一分钟顺时针转90度。
农民John深知牛的移动方法,他也这么移动。
每次(每分钟)农民John和两头牛的移动是同时的。如果他们在移动的时候穿过对方,但是没有在同一格相遇,我们不认为他们相遇了。当他们在某分钟末在某格子相遇,那么追捕结束。
读入十行表示农夫John,两头牛和所有障碍的位置的地图。每行都只包含10个字符,表示的含义和上面所说的相同,你可以确定地图中只有一个'F'和一个'C'.'F'和'C'一开始不会处于同一个格子中。
计算农夫John需要多少分钟来抓住他的牛,假设牛和农夫John一开始的行动方向都是正北(即上)。如果John和牛永远不会相遇,输出0。
PROGRAM NAME: ttwo
INPUT FORMAT
第1-10行:
每行10个字符,表示如上文描述的地图。
SAMPLE INPUT (file ttwo.in)
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......
OUTPUT FORMAT
输出一个数字,表示John需要多少时间才能抓住牛们。如果John无法抓住牛,则输出0。
SAMPLE OUTPUT (file ttwo.out)
49
======================== 华丽的分割线========================
这题的话, 应该属于模拟吧(专业术语不太清楚.), 反正就是不停的移动, 只是唯一的一点就是要考虑模拟的上限, 一共有100个方格, 4种方向, 所以单个(牛或者人)一共有400种情况, 那么一共就有160000种情况.
BIO '98 - Richard Forster
A pair of cows is loose somewhere in the forest. Farmer John is lending his expertise to their capture. Your task is to model their behavior.
The chase takes place on a 10 by 10 planar grid. Squares can be empty or they can contain:
an obstacle,
the cows (who always travel together), or
Farmer John.
The cows and Farmer John can occupy the same square (when they `meet') but neither the cows nor Farmer John can share a square with an obstacle. Each square is
represented
as follows:
. Empty square
* Obstacle
C Cows
F Farmer
Here is a sample grid:
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......
The cows wander around the grid in a fixed way. Each minute, they either move forward or rotate. Normally, they move one square in the direction they are facing. If there is an obstacle in the way or they would leave the board by walking `forward', then they spend the entire minute rotating 90 degrees clockwise.
Farmer John, wise in the ways of cows, moves in exactly the same way.
The farmer and the cows can be considered to move simultaneously during each minute. If the farmer and the cows pass each other while moving, they are not considered to have met. The chase ends when Farmer John and the cows occupy the same square at the end of a minute.
Read a ten-line grid that represents the initial state of the cows, Farmer John, and obstacles. Each of the ten lines contains exactly ten characters using the coding above. There is guaranteed to be only one farmer and one pair of cows. The cows and Farmer John will not initially be on the same square.
Calculate the number of minutes until the cows and Farmer John meet. Assume both the cows and farmer begin the simulation facing in the `north' direction. Print 0 if they will never meet.
PROGRAM NAME: ttwo
INPUT FORMAT
Lines 1-10: Ten lines of ten characters each, as explained above
SAMPLE INPUT (file ttwo.in)
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......
OUTPUT FORMAT
A single line with the integer number of minutes until Farmer John and the cows meet. Print 0 if they will never meet.
SAMPLE OUTPUT (file ttwo.out)
49
题目描述
两只牛逃跑到了森林里。农夫John开始用他的专家技术追捕这两头牛。你的任务是模拟他们的行为(牛和John)。
追击在10x10的平面网格内进行。一个格子可以是:
一个障碍物, 两头牛(它们总在一起), 或者 农民John. 两头牛和农民John可以在同一个格子内(当他们相遇时),但是他们都不能进入有障碍的格子。
一个格子可以是:
. 空地
* 障碍物
C 两头牛
F 农民John
这里有一个地图的例子:
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......
牛在地图里以固定的方式游荡。每分钟,它们可以向前移动或是转弯。如果前方无障碍且不会离开地图,它们会按照原来的方向前进一步。否则它们会用这一分钟顺时针转90度。
农民John深知牛的移动方法,他也这么移动。
每次(每分钟)农民John和两头牛的移动是同时的。如果他们在移动的时候穿过对方,但是没有在同一格相遇,我们不认为他们相遇了。当他们在某分钟末在某格子相遇,那么追捕结束。
读入十行表示农夫John,两头牛和所有障碍的位置的地图。每行都只包含10个字符,表示的含义和上面所说的相同,你可以确定地图中只有一个'F'和一个'C'.'F'和'C'一开始不会处于同一个格子中。
计算农夫John需要多少分钟来抓住他的牛,假设牛和农夫John一开始的行动方向都是正北(即上)。如果John和牛永远不会相遇,输出0。
PROGRAM NAME: ttwo
INPUT FORMAT
第1-10行:
每行10个字符,表示如上文描述的地图。
SAMPLE INPUT (file ttwo.in)
*...*.....
......*...
...*...*..
..........
...*.F....
*.....*...
...*......
..C......*
...*.*....
.*.*......
OUTPUT FORMAT
输出一个数字,表示John需要多少时间才能抓住牛们。如果John无法抓住牛,则输出0。
SAMPLE OUTPUT (file ttwo.out)
49
======================== 华丽的分割线========================
这题的话, 应该属于模拟吧(专业术语不太清楚.), 反正就是不停的移动, 只是唯一的一点就是要考虑模拟的上限, 一共有100个方格, 4种方向, 所以单个(牛或者人)一共有400种情况, 那么一共就有160000种情况.
/* LANG: C ID: zqy11001 PROG: ttwo */ #include <stdio.h> #define changemap(a, c) if(map[i][j] == c){\ a[0] = i;\ a[1] = j;\ map[i][j] = '.';\ } char way1[4] = {-1, 0, 1, 0}; char way2[4] = {0, 1, 0, -1}; char map[11][11]; char f[4], c[4]; void move(char *n) { int i, j; i = n[0] + way1[n[2]]; j = n[1] + way2[n[2]]; if(i > 10 || i < 1 || j > 10 || j < 1 || map[i][j] == '*'){ n[2] = (n[2] + 1) % 4; }else{ n[0] = i; n[1] = j; } } int main(void) { int i, j; freopen("ttwo.in", "r", stdin); freopen("ttwo.out", "w", stdout); for(i = 1; i <= 10; i++){ for(j = 1; j <= 10; j++){ scanf("%c", &map[i][j]); changemap(f, 'F'); changemap(c, 'C'); } getchar(); } for(i = 0; i < 160000 && (f[0] != c[0] || f[1] != c[1]); i++){ move(f); move(c); } printf("%d\n", i%160000); return 0; }
发表评论
-
重做 USACO 1.1 黑色星期五
2010-03-31 18:59 1300/* LANG: C ID: zqynux11 PROG ... -
重做 USACO 1.1 黑色星期五
2010-03-31 18:59 852解释什么的就算了吧,, /* LANG: C ID: ... -
重做 USACO 1.1 贪婪的送礼者
2010-03-31 18:58 1262这题的话, 我用的是个结构体, 记录各个人.. 我错了的地 ... -
重做 USACO 1.1 你的飞碟在这儿
2010-03-31 18:56 896不解释了.. /* LANG: C ID: zqynu ... -
USACO 3.1 Shaping Regions 形成的区域
2010-03-30 20:01 1548这题二话不说, 用map[i][j]表示坐标为i, j的点 ... -
USACO 3.1 Humble Numbers 丑数
2010-03-28 15:31 1497从这一题开始,, 以后题目我就不贴上来了... 自己去看吧 ... -
USACO 3.1 Score Inflation 总分
2010-03-27 20:19 852Score Inflation The more point ... -
USA 3.1 Agri-Net 最短网络
2010-03-27 20:14 900Agri-Net Russ Cox Farmer John ... -
USACO 2.4 Fractions to Decimals 分数化小数
2010-03-27 15:47 1306Fractions to Decimals Write a ... -
USACO 2.4 Bessie Come Home 回家
2010-03-27 13:01 1057Bessie Come Home Kolstad & ... -
USACO 2.4 Cow Tours 牛的旅行
2010-03-27 11:57 1140Cow Tours Farmer John has a nu ... -
USACO 2.4 Overfencing 穿越栅栏
2010-03-25 18:18 981USACO 2.4 Overfencing 穿越栅栏 Over ... -
USACO 2.3 Controlling Companies 控制公司
2010-03-23 22:00 1491Controlling Companies Some com ... -
USACO 1.1 Broken Necklace 破碎的项链
2010-03-22 18:04 2150Broken Necklace You have a neck ... -
USACO 2.3 Money Systems 货币系统
2010-03-22 13:31 999Money Systems The cows have no ... -
USACO 2.3 Cow Pedigrees 奶牛家谱
2010-03-21 15:02 1453Farmer John is considering purc ... -
USACO 2.3 Zero Sum 零的算式和
2010-03-20 14:30 1809Zero Sum Consider the sequence ... -
USACO Longest Prefix最长前缀
2010-03-17 12:28 1457Longest Prefix IOI'96 The stru ... -
vijos 谁拿了最多奖学金
2010-03-17 12:25 1121描述 Description 某校的惯例是在每 ... -
USACO 2.2 Subset Sums集合
2010-03-16 12:18 1486USACO 2.2 Subset Sums集合 For ...
相关推荐
在这个问题中,我们需要解决的是在一个10x10的网格环境中,农夫John如何尽快地追捕到两只在逃的塔姆沃斯牛。这个问题可以被视为一个简单的模拟问题,而不是复杂的图论算法,如Dijkstra或Floyd-Warshall。 题目描述...
[USACO2.4] 两只塔姆沃斯牛 The Tamworth Two是一个暴力枚举问题,给定一个 10 × 10 的图,其中有的格子是障碍物,有一个农夫在追一个牛。我们需要计算农夫多长时间可以追上牛。如果追不上,输出 0。 这个问题可以...
标题 "1_your ride is here_usaco_TheAnswer_YourRideisHere_" 指的是USACO(美国计算机奥林匹克)训练平台上的一个编程练习题目。USACO是一个专门为中学生提供在线编程训练和竞赛的平台,旨在提升参赛者的算法和...
此题目是USACO(美国计算机奥林匹克竞赛)中的一道编程题,名为"The Clocks"。题目要求解决的问题是找到一种最短的移动顺序,使得一个3x3矩阵中的9个时钟的指针全部指向12点。每个时钟有四个状态:3、6、9和12点,...
《USACO题目"Friday the Thirteenth"的代码解析》 USACO(美国计算机奥林匹克竞赛)是一场面向全球中学生举行的编程竞赛,旨在提升参赛者的算法设计和编程能力。"Friday the Thirteenth"是其中一道挑战题,目标是...
USACO,全称United States Computer Olympiad,是一项面向全球中学生的计算机编程竞赛,旨在提升参赛者的算法设计、编程能力和问题解决能力。本压缩包包含了USACO比赛的题解、源代码以及对应的中文翻译,对于想要...
USACO,全称为United States阿Olympiad in Informatics,是美国计算机奥林匹克竞赛,旨在为高中生提供一个学习和展示编程技能的平台。这个比赛涵盖了算法、数据结构以及问题解决等多个方面,对于想要深入理解计算机...
"USACO题集及答案"这个资源包含了两部分关键内容:一是题解文档,如"USACO题解(NOCOW整理版).doc",这很可能是参赛者或教练整理的一份详尽的题目解析,其中可能包括了对每个问题的描述、数据范围、预期输出以及解决...
【USACO大牛写的前三十个的代码】这个资源是一个集合,包含了由USACO(美国计算机奥林匹克)竞赛中表现出色的程序员编写的前30个代码实例。这些代码是针对初学者设计的,旨在帮助那些正在探索数据结构基础知识的人。...
### USACO 2010-2011 季度竞赛概览与关键信息 #### 一、概述 美国计算机奥林匹克(USACO)是面向全球中学生的计算机科学竞赛,旨在发掘并培养计算机科学领域的年轻人才。USACO 2010-2011 季度竞赛于 2010 年 11 月...
《USACO 合集:全面解析与学习指南》 USACO,全称为USA Computing Olympiad,是一项针对中学生举办的在线编程竞赛,旨在提升参赛者的算法设计和问题解决能力。这个合集提供了丰富的资源,包括英文原题、中文译题、...
USACO编程题中的一个,由一般方法编程,容易看懂,仅供交流。
USACO,全称为United States Computer Olympiad,是一项面向中学生的国际性计算机编程竞赛,旨在提升参赛者的算法设计和编程能力。USACO比赛通常使用C++语言进行,因此"USACO 1.1 c++源程序"指的是USACO入门阶段1.1...
【标题】"usaco traning全部数据" 涉及的是一个编程竞赛训练平台——USACO(USA Computing Olympiad)的数据集。USACO是一个专门为美国中学生设计的在线编程竞赛,旨在提升参赛者的算法设计和编程能力,特别是在解决...
USACO,全称United States Computer Olympiad,是一项面向全球中学生的计算机编程竞赛,旨在提升参赛者在算法设计、问题解决以及计算机科学基础方面的技能。这个压缩包文件提供了丰富的资源,帮助参赛者或学习者更好...
### USACO心得及总结 #### 第一部分 动态规划 **USACO**(美国计算机奥林匹克竞赛)作为一项国际知名的编程竞赛,不仅考验参赛者的编程能力,还对其算法理解和应用有着极高的要求。其中,动态规划(Dynamic ...
USACO(美国计算机奥林匹克竞赛)是面向全球中学生的一项编程竞赛,主要涉及算法和问题解决能力。这个压缩包文件“usaco历年测试数据”包含了该赛事历年的测试题目和样例输入输出数据,这对于参赛者准备比赛或者提升...
《USACO入门指南——第一章解析》 USACO,全称USA Computing Olympiad,是美国计算机奥林匹克竞赛,旨在培养中学生在算法和编程方面的技能。对于初学者来说,USACO提供了很好的学习路径和挑战。本文将针对USACO的第...
某些USACO题目的答案,很详细,代码清晰结构良好,算法高效易于调试
USACO,全称United States阿Olympiad in Computer Science,是美国计算机科学奥林匹克竞赛,旨在激发中学生对计算机科学的兴趣,尤其是算法和编程技能。这个"USACO全部测试数据.zip"压缩包包含了历年来USACO比赛的...