zoukankan      html  css  js  c++  java
  • [poj][2493][Rdeaalbe][map方法]

    题目:http://poj.org/problem?id=2493

    View Code
    #include <iostream>
    #include <sstream>
    #include <cstdio>
    #include <map>
    #include <algorithm>
    
    using namespace std;
    const int N = 10000+10;
    char str[N];
    
    int main(){
        //freopen("D:/a.txt", "r", stdin);
        int T, n, m, cas=1;
        scanf("%d", &T);
        while (T--){
            scanf("%d", &n); getchar();
            map<string, int> dict;
            for (int i=0; i<n; i++){
                gets(str);
                string word=str;
                if (word.size()>2) sort(word.begin()+1,word.end()-1);
                ++dict[word];
            }
            scanf("%d", &m);
            getchar();
            printf("Scenario #%d:\n", cas++);
            while (m--){
                gets(str);
                string line=str, word;
                int ans = 1;
                istringstream in(line);
                while (in >> word){
                    if (word.size()>2)
                        sort(word.begin()+1, word.end()-1);
                    ans *= dict[word];
                }
                printf("%d\n", ans);
            }
            puts("");
        }
        return 0;
    }
  • 相关阅读:
    Codeforces 1105C Ayoub and Lost Array
    绍兴市acm竞赛
    CodeForces#520 div2 1062B
    CodeForces#520 div2 1062A
    1067A
    测试MathJax
    BZOJ1010 玩具装箱toy
    停止
    秽翼
    爆零
  • 原文地址:https://www.cnblogs.com/nigel0913/p/2591706.html
Copyright © 2011-2022 走看看