The Heroes
来源:互联网 发布:网络监控工程宝 编辑:程序博客网 时间:2024/06/05 00:08
The Heroes
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
Submit Status
Dr. Suresh has discovered that special genetic pieceswould enable human beings to have special abilities, such as flying,self-healing, time-stopping, and so on. He would like to compile a listcontaining all such special people. An individual is on the list if and only ifhis genetic code contains one of the special pieces as a substring. Please helpDr.Suresh to do the task.
Input
The first linecontains an integer N, number of special genetic pieces. Following N lines each contain a string, the genetic code ofeach piece. On the next line is an integer M, number of individuals to be examined. Next M lines each has a string, which is the genetic codeof each individual.
- 1≤N≤10,1≤M≤50
- The length of any genetic code is greater than zero and does not exceed 50.
- A genetic code is a string containing A, T, C and G only and it doesn't contain any white spaces.
- String A is a substring of B, if and only if A appears continuously in B (e.g. ATC is a substring of AATCTC, but ATT isn't).
- A Hero's genetic code can contain multiple kinds of special genetic pieces as substrings.
Output
For each individual, if he is on the list, output A new hero discovered on a single line. Otherwise output Just an ordinary person instead.
Sample input and output
Sample Input
Sample Output
2
ATA
ATC
3
ACATAG
AATTCCGG
ATCGGATACG
A new hero discovered
Just an ordinary person
A new hero discovered
Source
The 5th UESTCProgramming Contest Preliminary
#include <stdio.h>#include <iostream>#include <string.h>#include <string>using namespace std;int main(){int n,m;string sp[20];string indi[60];int i,j;while (scanf("%d", &n)!=EOF){i=0;int t = n;while (n--)cin >> sp[i++];n = t;int f = 0;scanf("%d", &m);for (i=0; i<m; i++)cin >> indi[i];int k;for (k=0; k<m; k++){for (i=0; i<n; i++){int c;f = 0;for (j=0; j<indi[k].size(); j++){c = 0;int e = 0;int z=j;while (indi[k][z]==sp[i][e]){c++;z++;e++;if (c == sp[i].size()){f = 1;printf("A new hero discovered\n");break;}}if (f == 1)break;}if (f == 1)break;}if (f == 0)printf("Just an ordinary person\n");}}return 0;}
- The Heroes
- Hackers - Heroes Of The Computer Revolution
- the transition had too many heroes bow
- Java版桌面战棋游戏TLOH(The Legend of Heroes)开发预告
- 超能英雄 ( Heroes)
- Heroes in my heart
- Sonic Heroes- game doohickey
- Tiny Heroes:道高一尺,魔高一丈
- UVALive 3412 Pesky Heroes
- Codeforces 77A Heroes
- Heroes in My Heart (1)
- Heroes in My Heart (2)
- Heroes in My Heart (3)
- Heroes in My Heart (4)
- Heroes in My Heart (5)
- Heroes in My Heart (6)
- ZOJ 1346 Comparing Your Heroes
- Sonic Heroes组队必杀
- QT增加输入对话框
- JavaScript-3.1--获取用户的输入,输出用户输入的两数之和---ShinePans
- 星星评分
- 利用accept函数来处理客户端请求的连接
- 解决:自定义cocosbuilder插件属性不可编译的问题
- The Heroes
- QT增加消息对话框
- html5 式程序猿表白
- 浅谈Android五大布局(一)——LinearLayout、FrameLayout和AbsoulteLayout
- 利用connect函数创建客户端程序,连接前文编好的服务器程序
- 大话设计模式
- Azure编程笔记(3):用Fiddler调试Azure的应用程序
- C# 反射 Type Assembly类
- 浅谈Android五大布局(二)——RelativeLayout和TableLayout