HDU 4287 Intelligent IME [模拟]

这题就很傻逼,因为按出来的字母 对应 唯一的 数字按键。


代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
inline int Rint() { int x; scanf("%d", &x); return x; }
inline int max(int x, int y) { return (x>y)? x: y; }
inline int min(int x, int y) { return (x<y)? x: y; }
#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(x) for(int i=0; i<(x); i++)
typedef long long int64;
#define INF (1<<30)
const double eps = 1e-8;
#define bug(s) cout<<#s<<"="<<s<<" "

#define MAXN 5002
#define MAXM 5002

int tonum[] = 
{
	2, 2, 2,
	3, 3, 3,
	4, 4, 4,
	5, 5, 5,
	6, 6, 6,
	7, 7, 7, 7,
	8, 8, 8,
	9, 9, 9, 9
};

char ch[MAXM][10];
char di[MAXN][10];
map<int,  int> dic;

int main()
{
	int T = Rint();
	while(T--)
	{
		dic.clear();
		int n =Rint();
		int m = Rint();
		REP(n)
		{
			scanf("%s", di[i]);
		}
		REP(m)
		{
			scanf("%s", ch[i]);
			int ret = 0;
			for(int k=0; ch[i][k]; k++)
			{
				ret = ret*10 + tonum[ch[i][k]-'a'];
				dic[ret]++;
			}
		}
		REP(n)
		{
			int ret = 0;
			for(int k=0; di[i][k]; k++)
			{
				ret = ret*10 + di[i][k]-'0';
			}
			printf("%d\n", dic[ret]);
		}
	}
}


你可能感兴趣的:(HDU 4287 Intelligent IME [模拟])