hdu2222

maksyuki 发表于 oj 分类,标签:
0

Keywords Search

Problem Description

In the modern time, Search engine came into the life of everybody like Google, Baidu, etc.
Wiskey also wants to bring this feature to his image retrieval system.
Every image have a long description, when users type some keywords to find the image, the system will match the keywords with description of image and show the image which the most keywords be matched.
To simplify the problem, giving you a description of image, and some keywords, you should tell me how many keywords will be match.

Input

First line will contain one integer means how many cases will follow by.
Each case will contain two integers N means the number of keywords and N keywords follow. (N <= 10000)
Each keyword will only contains characters 'a'-'z', and the length will be not longer than 50.
The last line is the description, and the length will be not longer than 1000000.

Output

Print how many keywords are contained in the description.

Sample Input

1

5

she

he

say

shr

her

yasherhs

Sample Output

3

Author

Wiskey

 

题目类型:AC自动机

算法分析:直接将按照单词建立一个AC自动机,然后如果找到一个匹配的模式串,则不断寻找这个模式串的后缀,看能不能又找到一个匹配的模式串,防止漏解。注意使用G++会MLE!!!

 

hdu2191

maksyuki 发表于 oj 分类,标签:
0

念512汶川大地震遇难同胞——珍惜现在,感恩生活

Problem Description

急!灾区的食物依然短缺! 阅读全文 »

hdu2188

maksyuki 发表于 oj 分类,标签:
0

悼念512汶川大地震遇难同胞——选拔志愿者

Problem Description

对于四川同胞遭受的灾难,全国人民纷纷伸出援助之手,几乎每个省市都派出了大量的救援人员,这其中包括抢险救灾的武警部队,治疗和防疫的医护人员,以及进行心理疏导的心理学专家。根据要求,我校也有一个奔赴灾区救灾 阅读全文 »

hdu2152

maksyuki 发表于 oj 分类,标签:
0

Fruit

Problem Description

转眼到了收获的季节,由于有TT的专业指导,Lele获得了大丰收。特别是水果,Lele一共种了N种水果,有苹果,梨子,香蕉,西瓜……不但味道好吃,样子更是好看。

于是,很多人们慕名而来,找Lele买水果。 阅读全文 »

hdu2149

maksyuki 发表于 oj 分类,标签:
0

Public Sale

Problem Description

虽然不想,但是现实总归是现实,Lele始终没有逃过退学的命运, 阅读全文 »

hdu2141

maksyuki 发表于 oj 分类,标签:
0

Can you find it?

Problem Description

Give you three sequences of numbers A, B, C, then we 阅读全文 »

hdu2138

maksyuki 发表于 oj 分类,标签:
0

How many prime numbers

Problem Description

Give you a lot of positive integers, just to find out how many prime numbers there are. 阅读全文 »

hdu2098

maksyuki 发表于 oj 分类,标签:
0

分拆素数和

Problem Description

把一个偶数拆成两个不同素数的和,有几种拆法呢?

Input

输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。 阅读全文 »

hdu2067

maksyuki 发表于 oj 分类,标签:
0

小兔的棋盘

Problem Description

小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己的房间,拆开一看是一个棋盘,小兔有所失望。不过没过几天发现了棋盘的好玩之处。从起点(0,0)走到终点(n,n)的最短路径数是C(2n,n),现在小兔又想如果不穿越对角线(但可接触对角线上的格点),这样的路径数有多少?小兔想了很长时间都没想出来,现在想请你帮助小兔解决这个问题,对于你来说应该不难吧! 阅读全文 »

hdu2051

maksyuki 发表于 oj 分类,标签:
0

Bitset

Problem Description

Give you a number on base ten,you should output it on base two.(0 < n < 1000)

Input

For each case there is a postive number n on base ten, end 阅读全文 »

hdu2044

maksyuki 发表于 oj 分类,标签:
0

一只小蜜蜂...

Problem Description

有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。
其中,蜂房的结构如下所示。 阅读全文 »

hdu1950

maksyuki 发表于 oj 分类,标签:
0

Bridging signals

Problem Description

'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports of two functional blocks cross each other all over the place. At this late stage of the process, it is too
expensive to redo the routing. Instead, the engineers have to bridge the signals, using the third dimension, so that no two signals cross. However, bridging is a complicated operation, and thus it is desirable to bridge as few signals as possible. The call for a computer program that finds the maximum number of signals which may be connected on the silicon surface without rossing each other, is imminent. Bearing in mind that there may be housands of signal ports at the boundary of a functional block, the problem asks quite a lot of the programmer. Are you up to the task?

Figure 1. To the left: The two blocks' ports and their signal mapping (4,2,6,3,1,5). To the right: At most three signals may be routed on the silicon surface without crossing each other. The dashed signals must be bridged.

A typical situation is schematically depicted in figure 1. The ports of the two functional blocks are numbered from 1 to p, from top to bottom. The signal mapping is described by a permutation of the numbers 1 to p in the form of a list of p unique numbers in the range 1 to p, in which the i:th number pecifies which port on the right side should be connected to the i:th port on the left side.
Two signals cross if and only if the straight lines connecting the two ports of each pair do.

Input

On the first line of the input, there is a single positive integer n, telling the number of test scenarios to follow. Each test scenario begins with a line containing a single positive integer p<40000, the number of ports on the two functional blocks. Then follow p lines, describing the signal mapping: On the i:th line is the port number of the block on the right side which should be connected to the i:th port of the block on the left side.

Output

For each test scenario, output one line containing the maximum number of signals which may be routed on the silicon surface without crossing each other.

Sample Input

4

6

4

2

6

3

1

5

10

2

3

4

5

6

7

8

9

10

1

8

8

7

6

5

4

3

2

1

9

5

8

9

2

3

1

7

4

6

Sample Output

3

9

1

4

Source

NWERC2003

 

题目类型:LIS

算法分析:直接使用LIS求解即可

 

hdu1863

maksyuki 发表于 oj 分类,标签:
0

畅通工程

Problem Description

省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查 阅读全文 »

hdu1846

maksyuki 发表于 oj 分类,标签:
0

Brave Game

Problem Description

十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫《勇敢者的游戏》(英文名称:Zathura),一直到现在,我依然对于电影中的部分电脑特技印象深刻。 阅读全文 »

hdu1792

maksyuki 发表于 oj 分类,标签:
0

A New Change Problem

Problem Description

Now given two kinds of coins A and B,which satisfy that GCD(A,B)=1. 阅读全文 »

hdu1788

maksyuki 发表于 oj 分类,标签:
0

Chinese remainder theorem again

Problem Description

我知道部分同学最近在看中国剩余定理,就这个定理本身,还是比较简单的:
假设m1,m2,…,mk两两互素,则下面同余方程组: 阅读全文 »