zoukankan      html  css  js  c++  java
  • 51Nod 1095 Anigram单词

    熟练使用map即可,不然用vector会超时

     1 #include <iostream>
     2 #include <cstring>
     3 #include <string>
     4 #include <map>
     5 #include <algorithm>
     6 
     7 using  namespace std;
     8 map<string, int>q1, q2;
     9 //string 为索引
    10 
    11 int main(){
    12     ios::sync_with_stdio(false);
    13     int n, m;
    14     cin >> n;
    15     while (n--){
    16         string s;
    17         cin >> s;
    18         q1[s]++;
    19         sort(s.begin(), s.end());
    20         q2[s]++;
    21     }
    22     cin >> m;
    23     while (m--){
    24         string s;
    25         cin >> s;
    26         int ans1 = q1[s];
    27         sort(s.begin(), s.end());
    28         int ans2 = q2[s];
    29         cout << ans2 - ans1 << endl;
    30     }
    31     system("pause");
    32     return 0;
    33 }
  • 相关阅读:
    hdfs校验和
    hdfs读写策略
    hdfs架构
    hdfs数据块
    元数据
    集群的创建
    jQuery_DOM操作
    jQuery_简介_选择器
    Ajax
    MySQL整理_2_数据库操作
  • 原文地址:https://www.cnblogs.com/ouyang_wsgwz/p/8684284.html
Copyright © 2011-2022 走看看