Saruman's Army】的更多相关文章

Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8477   Accepted: 4317 Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes se…
http://poj.org/problem?id=3069 Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum…
POJ 3069 Saruman's Army(萨鲁曼军) Time Limit: 1000MS   Memory Limit: 65536K [Description] [题目描述] Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, know…
 Saruman's Army Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3069 Appoint description:  System Crawler  (2015-04-27) Description Saruman the White must lead his army along a straight path fro…
Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of …
Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13242   Accepted: 6636 Description Saruman the White must lead his army along a straight path from Isengard to Helm's Deep. To keep track of his forces, Saruman distributes s…
Saruman's Army Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 3   Accepted Submission(s) : 2 Problem Description Saruman the White must lead his army along a straight path from Isengard to Helm…
Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of R units, and…
题目连接 Description Saruman the White must lead his army along a straight path from Isengard to Helm's Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective rang…
Saruman the White must lead his army along a straight path from Isengard to Helm's Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of R units, and…
带来两题贪心算法的题. 1.给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下面两个操作:1.从S的头部删除一个字符,加到T的尾部.2.从S的尾部删除一个字符,加到T的尾部.求你任意采取这两个步骤后能得到的最小字符串T 2.直线上有N个点,点i的位置是xi,这N个点中选择若干个做上标记,对于每个点,在他们距离为R的区域内必须带有标记点,求在满足这个条件的情况下,所需要标记点的最少个数. 1.POJ 3617 Best Cow Line http://poj.…
Saruman the White must lead his army along a straight path from Isengard to Helm's Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of R units, and…
Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18794   Accepted: 9222 Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes s…
在一条直线上,有n个点.从这n个点中选择若干个,给他们加上标记.对于每一个点,其距离为R以内的区域里必须有一个被标记的点.问至少要有多少点被加上标记 Saruman the White must lead his army along a straight path from Isengard to Helm's Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, am…
2015-09-06 萨鲁曼军队 问题大意:萨鲁曼白想要让他的军队从sengard到Helm’s Deep,为了跟踪他的军队,他在军队中放置了魔法石(军队是一条线),魔法石可以看到前后距离为R的距离,为了让魔法石发挥最大的效益,魔法石戴在军人的身上,问你怎么才能使用最少的石头 问题很清晰,思路也很清晰,这道题挺典型的,就是贪心算法, 很容易想到的就是我们只用在距离内找到最后的点(人),然后把魔法石放到其上面就行了,然后依次类推,最后就可以达到最少的数量 具体可以以2R为一次循环,在前R的区间内我…
简单贪心. 从左边开始,找 r 以内最大距离的点,再在该点的右侧找到该点能覆盖的点.如图. 自己的逻辑有些混乱,最后还是参考书上代码.(<挑战程序设计> P46) /****************************************** Problem: 3069 User: Memory: 668K Time: 16MS Language: G++ Result: Accepted ******************************************/ #inc…
直线上有N个点.点i的位置是Xi.从这N个点中选择若干个,给它们加上标记.对每一个点,其距离为R以内的区域里必须又带有标记的点(自己本身带有标记的点,可以认为与其距离为0的地方有一个带有标记的点).在满足这个条件的情况下,希望能为尽可能少的点添加标记.请问至少要有多少点被加上标记? #include "iostream" #include "algorithm" using namespace std; const int MAX_N = 1000; int N=6…
https://vjudge.net/problem/POJ-3069 弄清楚一点,第一个stone的位置,考虑左右两边都要覆盖R,所以一般情况下不会在左边第一个(除非前两个相距>R). 一开始二层循环外层写的i=1,这样对于数据诸如1 1 1=>0,而其实结果是1. #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorith…
题目描述 Best Cow Line (POJ 3617) 给定长度为N的字符串S,要构造一个长度为N字符串T.T是一个空串,反复执行下列任意操作: 从S的头部删除一个字符,加到T的尾部: 从S的尾部删除一个字符,加到T的尾部: 目标是要构造字典序尽可能小的字符串T. 限制条件 1 <= N <= 2000 字符串 S 只包含大写英文字母 样例输入 N = 6 S = "ACDBCB" 样例输出 ABCBCD (如下图所示进行操作) 思路分析 不断取S的开头和结尾中较小的一…
一.题面 POJ3069 二.题意分析 我的理解是,可以在每个点设置一个监测点,能够监测到范围R内的所有其他点,那么问给出N个点的一维位置,需要在其中挑多少个监测点把所有点都监测到. 贪心解决: 1.先排序. 2.考虑第一个点,因为每个点是必须要监测的,那么第一个点需要被监测到,它可以是监测点,也可以是被监测点.贪心的想,为了能监测更多的点,让第一个点作为被监测的点,且是监测范围内最边界上的点. 3.现在需要考虑,当第一个点往右探测R范围时,最后一个点将是需要设置的监测点. 4.以这个监测点再往…
链接:http://poj.org/problem?id=3069 题解 #include<iostream> #include<algorithm> using namespace std; ; int N,R; // N是部队数,R是有效射程 int X[MAX]; void solve(){ sort(X,X+N); ,ans=; while(i<N){ // s是没有被覆盖的最左边的点的位置 int s=X[i++]; //一直向右前进直到距 s的距离大于 R的点,此…
地址 http://poj.org/problem?id=3069 题解 题目可以考虑贪心 尽可能的根据题意选择靠右边的点 注意 开始无标记点 寻找左侧第一个没覆盖的点 再来推算既可能靠右的标记点为一轮 我最开始就是轮次的操作理解错误 结果wa了 ac代码如下 #include <iostream> #include <vector> #include <algorithm> using namespace std; /* poj3069 题目大意:一个直线上有N个点.…
此题的策略是选取可用范围最右边的点,一般来说该点辐射两边,左侧辐射,右侧辐射,所以用两个循环,第一个循环找出该点,第二个循环求出最右边的点 源代码: #include<iostream>#include<algorithm>using namespace std;#define maxn 1100int main(){    int r,n,k=0,num=0,x,a[maxn];    cin>>n;    for(int i=0;i<n;i++) cin>…
直线上有N个点. 点i的位置是Xi.从这N个点中选择若干个,给它们加上标记. 对每一个点,其距离为R以内的区域里必须有带有标记的点(自己本身带有标记的点, 可以认为与其距离为 0 的地方有一个带有标记的点). 在满足这个条件的情况下, 希望能为尽可能少的点添加标记. 请问至少要有多少点被加上标记? 输入 N = 6 R = 10 X = (1, 7, 15, 20, 30, 50} 输出 3 java实现 import java.util.Scanner; public class Main {…
万恶之源 目录 题意 思路 贪心的原则是什么呢? 错解 正解 代码实现 书上的代码 我的代码 比较一下 问题 题意 给定若干个点的坐标,与范围R.每个点可以选择是否标记,标记后这个点的左右范围R内的所有点也会被标记,求为使所有点被标记,我们要主动标记多少个点. 思路 这题总感觉可以用搜索做,毕竟每个点的状态要么是1要么是0.但这是书上贪心的例题,那肯定得用贪心做啦. 贪心的原则是什么呢? 错解 首先我们的目标是尽可能少的标记,因此我们当然可以希望每次一次性标记的点越多越好,那么我们是不是可以遍历…
萨鲁曼的军队(Saruman's Army) 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 直线上有N个点, 每个点, 其距离为R以内的区域里, 必须带有标记的点, 本身的距离为0. 尽可能少的加入�标记点, 至少要有多少点被加上标记? 贪心算法, 从最左边的点開始, 依次查找距离为R须要加入�标记的点, 直到结束. 代码: /* * main.cpp * * Created on: 2014.7.17 * Author: spike *…
Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6688   Accepted: 3424 Description Saruman the White must lead his army along a straight path from Isengard to Helm's Deep. To keep track of his forces, Saruman distributes se…
Description Saruman’s army of orcs and other dark minions continuously mine and harvest lumber out of the land surrounding his mighty tower for N continuous days. On day number i, Saruman either chooses to spend resources on mining coal and harvestin…
Profile Introduction to Blog 您能看到这篇博客导读是我的荣幸.本博客会持续更新.感谢您的支持.欢迎您的关注与留言.博客有多个专栏,各自是关于 Android应用开发 .Windows App开发 . UWP(通用Windows平台)开发 . SICP习题解 和 Scheme语言学习 . 算法解析 与 LeetCode等题解 .而近期会加入的文章将主要是算法和Android.只是其他内容也会继续完好. About the Author 独立 Windows App 和…
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1019 Grandpa's Other Estate 1034 Simple Arithmetics 1036 Complete the sequence! 1043 Maya Calendar 1054 Game Prediction 1057 Mileage Bank 1067 Rails 10…