poj3913 Gnome Sequencing
2015-09-14 19:42
435 查看
Gnome Sequencing
Description
In the book All Creatures of Mythology, gnomes are kind, bearded creatures, while goblins tend to be bossy and simple-minded. The goblins like to harass the gnomes by making them line up in groups of three, ordered by the length of their beards. The gnomes,
being of different physical heights, vary their arrangements to confuse the goblins. Therefore, the goblins must actually measure the beards in centimeters to see if everyone is lined up in order.
Your task is to write a program to assist the goblins in determining whether or not the gnomes are lined up properly, either from shortest to longest beard or from longest to shortest.
Input
The input starts with line containing a single integer N, 0 < N < 30, which is the number of groups to process. Following this are N lines, each containing three distinct positive integers less than 100.
Output
There is a title line, then one line per set of beard lengths. See the sample output for capitalization and punctuation.
Sample Input
Sample Output
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2220 | Accepted: 1517 |
In the book All Creatures of Mythology, gnomes are kind, bearded creatures, while goblins tend to be bossy and simple-minded. The goblins like to harass the gnomes by making them line up in groups of three, ordered by the length of their beards. The gnomes,
being of different physical heights, vary their arrangements to confuse the goblins. Therefore, the goblins must actually measure the beards in centimeters to see if everyone is lined up in order.
Your task is to write a program to assist the goblins in determining whether or not the gnomes are lined up properly, either from shortest to longest beard or from longest to shortest.
Input
The input starts with line containing a single integer N, 0 < N < 30, which is the number of groups to process. Following this are N lines, each containing three distinct positive integers less than 100.
Output
There is a title line, then one line per set of beard lengths. See the sample output for capitalization and punctuation.
Sample Input
3 40 62 77 88 62 77 91 33 18
Sample Output
Gnomes: Ordered Unordered Ordered
分析:输入三个数,判断是否为有序序列。
分析:数据很小,直接比较就行,注意输出是所有结果一起输出。
#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1000000007; #define ll long long #define CL(a) memset(a,0,sizeof(a)) int a,b,c,n,k; char s[33][11]; bool flag; int main () { cin>>n; k = 0; while (n--) { cin>>a>>b>>c; flag=false; if((a<=b&&b<=c)||(a>=b&&b>=c)) flag=true; if(flag) strcpy(s[k++], "Ordered"); else strcpy(s[k++], "Unordered"); } cout<<"Gnomes:"<<endl; for(int i=0; i<k; i++) cout<<s[i]<<endl; return 0; }
相关文章推荐
- Android 中使用rawquery方法查询指定数据的一些方法总结
- Redrain duilib中的名字空间问题
- duilib lib库静态变量初始化问题
- 处理美国时间 Tue May 31 17:46:55 +0800 2011
- What is an intuitive explanation of the relation between PCA and SVD?
- JSP 请求对象 request
- HDU1159Common Subsequence DP
- JAVA-有趣的GuessBirthday
- 可以输出自己的源程序代码(quine)
- Android SystemUI中HOME key的处理
- IOS开发模块总结(二)后台运行程序(2)Task completion-UIBackgroundTaskIdentifier
- 【EGit】The current branch is not configured for pull No value for key branch.master.merge found in config
- UITableView headView固定效果实现
- 使用 Arduino 和 LM35 温度传感器监测温度
- quick2.2与quick3.3的区别(4)
- could not find implicit value for parameter extractor 问题的解决
- neclues lwip 的 bind、send 发送调用过程和等待唤醒条件
- 两个对象值相同(x.equals(y) == true),但却可有不同的hash code,这句话对不对
- 两个对象值相同(x.equals(y) == true),但却可有不同的hash code,这句话对不对
- 两个对象值相同(x.equals(y) == true),但却可有不同的hash code,这句话对不对