A 2012 Tianjin Network qualifying questions, registration questions.
But still write for thirty or forty minutes, C + + and STL is too unfamiliar, always compile errors do not know how to solve.
The first char [] was later changed to String,stl and string to be used together.
1#include <algorithm>2#include <iostream>3#include <cstring>4#include <ctype.h>5#include <cstdlib>6#include <cstdio>7#include <vector>8#include <string>9#include <queue>Ten#include <stack> One#include <cmath> A#include <Set> -#include <map> - the using namespacestd; - - intn,m,t; -Map <string,int>dic; + stringlist[5010]; - inttable[]={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}; + intMain () A { atCIN >>T; - strings; - while(t--) - { -CIN >> N >>M; - for(intI=0; i<n;i++) { inCIN >>List[i]; - } to dic.clear (); + for(intI=0; i<m;i++) - { theCIN >>s; * stringnum; $ for(intk=0; K < (int) s.size (); k++)Panax Notoginseng { -num + = table[s[k]-'a'] +'0'; the } + //cout << num << endl; Amap<string,int>::iterator it =dic.find (num); the if(It = =Dic.end ()) { +Dic.insert (num, Make_pair1)); - } $ Else $it->second++; - } -map<string,int>:: Const_iterator notFound (Dic.end ()); themap<string,int>:: Const_iterator pos; - for(intI=0; i<n;i++)Wuyi { the if(pos = Dic.find (list[i)) = =notFound) -printf"0\n"); Wu Else -printf"%d\n",pos->second); About } $ } -}
Hdu4287-stl Simulated water problem