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 ATC 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;}


0 0
原创粉丝点击