【51Nod】1095 - Anigram单词(STL - map)
2017-02-28 17:08
447 查看
题目链接:点击打开题目
题解:直接用map记录,然后排序再记录,相减就求出来了。
代码如下:
题解:直接用map记录,然后排序再记录,相减就求出来了。
代码如下:
#include <cstdio> #include <iostream> #include <cstring> #include <queue> #include <cmath> #include <stack> #include <vector> #include <map> #include <string> #include <algorithm> using namespace std; #define INF 0x3f3f3f3f #define CLR(a,b) memset(a,b,sizeof(a)) #define PI acos(-1.0) #define LL long long int main() { int n; map<string,int> a; //字符串出现次数 map<string,int> b; //排序后字符串出现次数 string str; scanf ("%d",&n); while (n--) { cin >> str; a[str]++; sort(str.begin(),str.end()); b[str]++; } scanf ("%d",&n); while (n--) { cin >> str; int x = a[str]; sort(str.begin(),str.end()); int y = b[str]; printf ("%d\n",y-x); } return 0; }
相关文章推荐
- 51nod 1095 Anigram单词 (map——multiset结合)
- 51nod 1095 Anigram单词(map)
- 51nod 1095 Anigram单词 【map的使用】
- 51Nod 1095 Anigram单词 map
- 51nod oj 1095 Anigram单词【map】
- 51Nod 1095 Anigram单词 | Hash
- 51nod 1095 Anigram单词
- 51nod 1095 Anigram单词
- 51nod-1095 Anigram单词
- 51NOD 1095 Anigram单词
- 51Nod - 1095 Anigram单词
- 51 nod 1095 Anigram单词 利用map处理hash问题
- 51NOD 1095 Anigram单词
- 51nod 1095 Anigram单词
- 【51nod】--1095Anigram单词(STL~~map)
- 51nod 1095 Anigram单词
- 51nod 1095 Anigram单词
- 51Nod 1095 Anigram单词
- [51Nod](1095)Anigram单词 ---- Hash(map)+排序
- 51nod 1095 Anigram单词