Andy's First Dictionary ,样例过了,一直WA,求大佬指教

How Many Maos Does the Guanxi Worth
Problem Description
"Guanxi" is a very important word in Chinese. It kind of means "relationship" or "contact". Guanxi can be based on friendship, but also can be built on money. So Chinese often say "I don't have one mao guanxi with you." or "The guanxi between them is naked money guanxi." It is said that the Chinese society is a guanxi society, so you can see guanxi plays a very important role in many things.



UVA10815 Andy's First Dictionary

Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is, well, not quite enough. Instead of thinking up all the words himself, he has a briliant idea. From his bookshelf he would pick one of his favourite story books, from which he would copy out all the distinct words. By arranging the words in alphabetical order, he is done! Of course, it is a really time-consuming job, and this is where a computer program is helpful.

You are asked to write a program that lists all the different words in the input text. In this problem, a word is defined as a consecutive sequence of alphabets, in upper and/or lower case. Words with only one letter are also to be considered. Furthermore, your program must be CaSe InSeNsItIvE. For example, words like "Apple", "apple" or "APPLE" must be considered the same.


The input file is a text with no more than 5000 lines. An input line has at most 200 characters. Input is terminated by EOF.


Your output should give a list of different words that appears in the input text, one in a line. The words should all be in lower case, sorted in alphabetical order. You can be sure that he number of distinct words in the text does not exceed 5000.

Sample Input

Adventures in Disneyland

Two blondes were going to Disneyland when they came to a fork in the
road. The sign read: "Disneyland Left."

So they went home.

Sample Output


using namespace std;

int main()
string s,b[1000010];
int i=0;

while(cin>>s) //连续读入 { for(int n = 0; n < s.size //去掉标点符号 { if(!ispunct { b[i] += s[n]; } } //大写变小写 for(int n = 0; n < b[i].size { b[i][n] = tolower; } i++; }sort; //按字母表顺序排序for(int k = 0; k < i; k++) { int flag = 0; for(int j = 0; j < k; j++) //删去重复的字符串,注意条件j < k { if(b[k] == b[j]) flag = 1; } if cout<<b[k]<<endl; }return 0;


Here is an example. In many cities in China, the government prohibit the middle school entrance examinations in order to relief studying burden of primary school students. Because there is no clear and strict standard of entrance, someone may make their children enter good middle schools through guanxis. Boss Liu wants to send his kid to a middle school by guanxi this year. So he find out his guanxi net. Boss Liu's guanxi net consists of N people including Boss Liu and the schoolmaster. In this net, two persons who has a guanxi between them can help each other. Because Boss Liu is a big money(In Chinese English, A "big money" means one who has a lot of money) and has little friends, his guanxi net is a naked money guanxi net -- it means that if there is a guanxi between A and B and A helps B, A must get paid. Through his guanxi net, Boss Liu may ask A to help him, then A may ask B for help, and then B may ask C for help ...... If the request finally reaches the schoolmaster, Boss Liu's kid will be accepted by the middle school. Of course, all helpers including the schoolmaster are paid by Boss Liu.

Words and phrases containing dogs (Gou in Chinese) are commonly used by young people when cracking jokes about themselves.

Nowadays, There are many people keeping pets. To those people, pets are parts of their family and have made their lives more colorful. From my perspectives, it's good to have a close relationship with pets, which can be good companions for us as well as a kind of lubricants between us and the world.

You hate Boss Liu and you want to undermine Boss Liu's plan. All you can do is to persuade ONE person in Boss Liu's guanxi net to reject any request. This person can be any one, but can't be Boss Liu or the schoolmaster. If you can't make Boss Liu fail, you want Boss Liu to spend as much money as possible. You should figure out that after you have done your best, how much at least must Boss Liu spend to get what he wants. Please note that if you do nothing, Boss Liu will definitely succeed.


A close relationship with pets can keep us away from loneliness. There are many pictures on wechat about lives with pets, usually dogs, including feeding them, walking with them, giving them a bath. The happy atmosphere shows us what good companions those pets have been.

There are several test cases.

For example, in Mandarin, you can say "Valentine's Day has nothing to do with me since I am a single dog."


For each test case:



必威,The first line contains two integers N and M. N means that there are N people in Boss Liu's guanxi net. They are numbered from 1 to N. Boss Liu is No. 1 and the schoolmaster is No. N. M means that there are M guanxis in Boss Liu's guanxi net. (3 <=N <= 30, 3 <= M <= 1000)

必威 1

Being close with pets can not only give ourselves warmth, but also break the ice between us and the outside world.

Then M lines follow. Each line contains three integers A, B and C, meaning that there is a guanxi between A and B, and if A asks B or B asks A for help, the helper will be paid C RMB by Boss Liu.

"Overtime dog" is another title frequently referred to those who work long hours.

People living in a metropolis are wary of others, filled with ideas on how to make more money than how to build pleasant relationships between us and other people. Close relationships between us and pets require thoughtfulness, love which can help us have nice attitude towards other people.For example, Once I saw a lady walking with a pet dog. They stopped at a crossing, waiting for the green light. The lady embraced the dog with softness full of her eyes. At that moment, a stranger passed by with a question about his destination. The lady smiled at him and gave him patient instructions.I'm sure it's her love towards her pet that had given contribution to her kindness towards other people, including strangers.

The input ends with N = 0 and M = 0.



It's guaranteed that Boss Liu's request can reach the schoolmaster if you do not try to undermine his plan.

It is believed that words and phrases like these containing humor and self-deprecation ease the stigma attached to dog-related words.

In one word, keeping pets closely can provide warmth not only to ourselves, but also to others. It's helpful.

For each test case, output the minimum money Boss Liu has to spend after you have done your best. If Boss Liu will fail to send his kid to the middle school, print "Inf" instead.


Sample Input
4 5
1 2 3
1 3 7
1 4 50
2 3 4
3 4 2
3 2
1 2 30
2 3 10
0 0

#Representation of close relationship

Sample Output


Adding "dog" to a friend's name can also be considered as a proof of a close relationship.


必威 2

One of the most prominent examples in China is that of the actor Lin Gengxin, who is called Lin Gou - Chinese for Lin Dog - by his celebrity friends and beloved fans.


必威 3

#Easy to raise


Children with amiable names are easy to bring up, according to an ancient Chinese proverb.


Parents in rural areas prefer to give nicknames including Gou Sheng and Gou Dan to their children in the hope that they are as easy to be fostered as dogs.


必威 4



Since dogs are considered to be loyal and diligent, the word is included in more than 10 Chinese metaphors.


For instance, "serve like a dog or a horse," is used to describe someone who is ready to render his humble services to the authorities.


"Dogs don't bark to their owners" is an idiom usually adopted to represent the loyalty of ministers to their monarchs.