ZOJ 3207 80ers' Memory (F)

80ers‘ Memory


Time Limit: 1 Second      Memory Limit: 32768 KB


I guess most of us are so called 80ers, which means that we were born in the 1980‘s. This group of people shared a lot of common memories. For example, the Saint Seiya, the YoYo ball, the Super Mario, and so on. Do you still remember these?

Input

There will be ONLY ONE test case.

The test case begins with a positive integer N, (N < 100).
Then there will be N lines each containing a single word describing a keyword of the typical 80ers‘ memories. Each word consists of letters, [a-zA-Z], numbers, [0-9], and the underline, ‘_‘. The length of each word would be no more than 20.
Then one line follows with a positive integer K, (K < 100).
The last part of the test case will be K lines. The i-th line contains the keywords given by the i-th person and starts with a positive integer Ni. Then there will be Ni words separated by white spaces. Each of these words has no more than 20 characters.
All the words are case sensitive.

Output

For each of these K people, you are asked to count the number of typical 80ers‘ keywords on his/her list and output it in a single line.

Sample Input

4
Saint_Seiya
YoYo_ball
Super_Mario
HuLuWa
3
2 Saint_Seiya TiaoFangZi
1 KTV
3 HuLuWa YOYO_BALL YoYo_ball

Sample Output

1
0
2

水题
 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdio>
 4 #include <string>
 5 using namespace std;
 6 #define maxn 105
 7 int N, K;
 8 string s[maxn];
 9 struct Node{
10     int n;
11     string word[maxn];
12 }node[maxn];
13 int main(){
14     scanf("%d", &N);
15     for(int i = 1; i <= N; i++) cin>>s[i];
16     scanf("%d", &K);
17     for(int i = 1; i <= K; i++){
18         scanf("%d", &node[i].n);
19         for(int j = 1; j <= node[i].n; j++) cin>>node[i].word[j];
20     }
21
22     for(int i = 1; i <= K; i++){
23         int cnt = 0;
24         for(int j = 1; j <= node[i].n; j++){
25             for(int k = 1; k <= N; k++){
26                 if(node[i].word[j] == s[k]){
27                     cnt++;break;
28                 }
29             }
30         }
31         printf("%d\n", cnt);
32     }
33
34     return 0;
35 }

ZOJ 3207 80ers' Memory (F),布布扣,bubuko.com

ZOJ 3207 80ers' Memory (F)

时间: 2024-08-10 12:00:13

ZOJ 3207 80ers' Memory (F)的相关文章

ZOJ 3207: 80ers&#39; Memory

ZOJ 3207:: 80ers' Memory ///@author Sycamore, ZJNU ///@date 2017-02-09 #include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; int main() { int N; cin >> N; vector<string>v(N); for 

ZOJ 3204 Connect them (C) 最小生成树kruskal

Connect them Time Limit: 1 Second      Memory Limit: 32768 KB You have n computers numbered from 1 to n and you want to connect them to make a small local area network (LAN). All connections are two-way (that is connecting computers i and j is the sa

zoj 2913 Bus Pass (BFS)

Bus Pass Time Limit: 5 Seconds      Memory Limit: 32768 KB You travel a lot by bus and the costs of all the seperate tickets are starting to add up. Therefore you want to see if it might be advantageous for you to buy a bus pass. The way the bus syst

ZOJ 2477 Magic&#160;Cube(魔方)

ZOJ 2477 Magic Cube(魔方) Time Limit: 2 Seconds      Memory Limit: 65536 KB This is a very popular game for children. In this game, there's a cube, which consists of 3 * 3 * 3 small cubes. We can unwrap the cube, it will become like this: 这是个有名的儿童游戏.游戏

ZOJ 3202 Second-price Auction (A)

Second-price AuctionTime Limit: 1 Second Memory Limit: 32768 KBDo you know second-price auction? It's very simple but famous. In a second-price auction, each potential buyer privately submits, perhaps in a sealed envelope or over a secure connection,

ZOJ 2836 Number Puzzle ( 容斥原理 )

ZOJ 2836 Number Puzzle( 容斥原理 ) #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long LL; #define CLR( a, b ) memset( a, b, sizeof(a) ) int m, n, A[11]; LL gcd( LL a, LL b ) { return b == 0 ? a :

zoj 3103 Cliff Climbing(spfa )

Cliff Climbing Time Limit: 10 Seconds      Memory Limit: 32768 KB At 17:00, special agent Jack starts to escape from the enemy camp. There is a cliff in between the camp and the nearest safety zone. Jack has to climb the almost vertical cliff by step

编译时:virtual memory exhausted: Cannot allocate memory(转)

一.问题 当安装虚拟机时系统时没有设置swap大小或设置内存太小,编译程序会出现virtual memory exhausted: Cannot allocate memory的问题,可以用swap扩展内存的方法. 二.解决方法 在执行free -m的是时候提示Cannot allocate memory: (swap文件可以放在自己喜欢的位置如/var/swap) 1 [[email protected] byrd]# free -m 2 total used free shared buff

【ZOJ 3856】Goldbach(FFT)

题意:最多使用三个质数做加法和乘法,问得到X有多少种方案. 这道题的话分几种情况讨论清楚就好了. 1.只有一个数的情况,如果这个数是质数则方案数加1 2.有两个数的情况,可以将两个数做加法和乘法,加法的话将质数得到的数字做一遍FFT,乘法直接做sqrt(n) * sqrt(n)就好了 3.有三个数的情况,分别有三种方法,分别是a + b + c, a + b * c,a * b * c 对于a * b * c,暴力遍历一遍就好,对于a + b * c,首先暴力遍历下b * c,然后再将一个数的两