zoukankan      html  css  js  c++  java
  • POJ 2503 Babelfish

    题意:给出一个字典,每条包含两个字符串a和b,空一行给出若干查询,查询给出b求a。

    解法:map乱搞……据说是个字典树……并不会字典树……TAT

    一直在T……看题解改了一些函数……长姿势了……不过应该是数据加强了的样子……关闭了cincout的同步流……快了不少TUT

    代码:

    #include<stdio.h>
    #include<iostream>
    #include<algorithm>
    #include<string>
    #include<string.h>
    #include<math.h>
    #include<limits.h>
    #include<time.h>
    #include<stdlib.h>
    #include<map>
    #include<queue>
    #include<set>
    #include<stack>
    #include<vector>
    #define LL long long
    using namespace std;
    map <string, string> m;
    int main()
    {
        ios :: sync_with_stdio(false);
        string s1;
        while(getline(cin, s1))
        {
            if(s1.size() == 0)
                break;
            string s2, s3;
            int i = s1.find_first_of(' ');
            s2 = s1.substr(0, i);
            int j = s1.find_first_not_of(' ', i);
            s3 = s1.substr(j, s1.length() - j);
            m[s3] = s2;
        }
        string s;
        while(cin >> s)
        {
            int i = m.count(s);
            if(i > 0)
                cout << m[s] << endl;
            else
                cout << "eh" << endl;
        }
        return 0;
    }
    

      

  • 相关阅读:
    检测mysq组复制的脚本
    centos7安装NFS
    mysql组复制安装
    springboot+VUE(一)
    redis集群配置
    codevs 3139 栈练习3
    codevs 3138 栈练习2
    codevs 2622 数字序列
    codevs 1054 电梯
    codevs 1507 酒厂选址
  • 原文地址:https://www.cnblogs.com/Apro/p/4531421.html
Copyright © 2011-2022 走看看