POJ-3617】的更多相关文章

POJ 3617 Best Cow Line Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual "Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds…
带来两题贪心算法的题. 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.…
P2870 [USACO07DEC]最佳牛线,黄金Best Cow Line, Goldpoj 3617 http://poj.org/problem?id=3617 题目描述FJ is about to take his N (1 ≤ N ≤ 500,000) cows to the annual”Farmer of the Year” competition. In this contest every farmer arranges his cows in a line and herds…
http://poj.org/problem;jsessionid=F0726AFA441F19BA381A2C946BA81F07?id=3617 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and her…
题目链接:http://poj.org/problem?id=3617 题目意思:给出一条长度为n的字符串S,目标是要构造一条字典序尽量小,长度为n的字符串T.构造的规则是,如果S的头部的字母 < S的尾部的字母,那么将S的头部的字母加入到T中,删除S的头部的字母:如果S的头部的字母 > S的尾部的字母,那么将S的尾部的字母加入到T中,删除S的尾部的字母. 这个题目的关键是如何处理 S 的头部的字母(假设用 i 指示) = S的尾部的字母(j) 这种情况.此时需要比较 i+1 和 j-1 的位…
原题链接:http://poj.org/problem?id=3617 问题梗概:给定长度为 的字符串 , 要构造一个长度为 的字符串 .起初, 是一个空串,随后反复进行下列任意操作. 从 的头部删除一个字符,加到 的尾部. 从 的尾部删除一个字符,加到 的尾部. 目的是要构造字典序尽可能小的字符串 .     限制条件: 字符串 只包含大写英文字母 输出的字符串每 80 个字符进行一次换行 字典序是指从前到后比较两个字符串大小的方法.首先比较第 1 个字符,如果不同则第 1 个字符较小的字符串…
Best Cow Line   Time Limit: 1000MS      Memory Limit: 65536K Total Submissions: 16104    Accepted: 4547 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arrang…
题意:给定一行字符串,让你把它变成字典序最短,方法只有两种,要么从头部拿一个字符,要么从尾部拿一个. 析:贪心,从两边拿时,哪个小先拿哪个,如果一样,接着往下比较,要么比到字符不一样,要么比完,也就是说从头部和尾部拿都一样,那么就随便拿一个了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <…
题目: 给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下列任意操作. ·从S的头部删除一个字符,加到T的尾部 ·从S的尾部删除一个字符,加到T的尾部 目标是要构造字典序尽可能小的字符串T. #include "iostream" #include "cstring" #include "vector" using namespace std; #define MAX_N 1000 void solve(in…
Best Cow Line Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30684   Accepted: 8185 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his…
Best Cow Line Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9284   Accepted: 2826 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his…
题目链接 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges. The contest organizers adopted a new registra…
注意是说的80个字母一行....…
Best Cow Line Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 26670   Accepted: 7226 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his…
比赛的时候扣了一道贪心的题目,不会写,,现在补一补一些基础的贪心. 题意:给定一个字符串s,要求按下列操作生成一个新串t--每次从s串中的最前和最后取一个字符给t,要求生成的t字典序最小. 题解:由于是要求字典序最小,满足局部最优的思想贪心的取就可以了(这里要注意的是相等的情况) ac代码: #include <cstdio> #include <iostream> #include <cstring> #include <queue> using name…
Best Cow Line Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 42701   Accepted: 10911 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges hi…
#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> using namespace std; int ma…
题目 POJ 3617 和 这道题题目一样,只是范围稍稍再小一点. //模拟试试 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ][]; bool bijiao(int st,int ed) { if(st==ed) return true; ]<s[ed][]) return true; ]>s[ed][]) return false; else…
POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 Ball POJ 3009 Curling 2.0 AOJ 0558 Cheese POJ 3669 Meteor Shower AOJ 0121 Seven Puzzle POJ 2718 Smallest Difference POJ 3187 Backward Digit Sums POJ 3…
题目描述 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的开头和结尾中较小的一…
[SinGuLaRiTy-1024] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. [POJ 2709] 颜料 (Painter) 题目描述 杂货店出售一种由N(3<=N<=12)种不同颜色的颜料,每种一瓶(50ML),组成的颜料套装.你现在需要使用这N种颜料:不但如此,你还需要一定数量的灰色颜料.杂货店从来不出售灰色颜料——也就是它不属于这N种之一.幸运的是,灰色颜料是比较好配置的,如果你取出三种不同颜色的颜料各x ml,混合起来就…
问题: 链接:http://poj.org/problem?id=3617 思路: 按照字典序比较S和将S反转后的字符串S' 如果S较小,就从S的开头取出一个字符,加到T的末尾(更新下标值) 如果S’较小,从S’的末尾取出一个字符,加到T的末尾(更新下标值) 代码: # include <iostream> # include <string> using namespace std; int N; ]; ]; int main() { cin>>N; ; i <…
[B007]Best Cow Line[难度B]———————————————————————————————————————————————— [Description    支持原版从我做起!!!] FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in…
Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798   Special Judge Description Every year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286   Accepted: 8603   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…
Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yumm…
Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050   Accepted: 10989 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio…
Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 Description Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital le…