zoukankan      html  css  js  c++  java
  • cdoj 71 I am Lord Voldemort 水题

    I am Lord Voldemort

    Time Limit: 20 Sec  Memory Limit: 256 MB

    题目连接

    http://acm.uestc.edu.cn/#/problem/show/71

    Description

    f you have ever read Harry Potter, you would know that the evil and powerful wizard, Lord Voldemort, create this name by permuting his original name, Tom Marvolo Riddle, to I am Lord Voldemort.

    Write a program to check whether it is possible to transform a given word to another by permuting its letters.

    The length of any given word is greater than 0 and no larger than 50.

    Input

    The first line is an integer T, the number of test cases. Following T lines each contains two words separated by spaces.

    Output

    For each test case, Output on a line Yes if it is possible to do the transformation, otherwise output No instead.

    Permuting a word is to change the order of its letters, but no new letters can be added and no original letters can be deleted. For example, one can transform aabc to abca, but not to bac, abc, aabca, aacbb.

    Words will contain letters only(a-z, A-Z).

    A word won't contain any white spaces in itself.

    The given two words will not be the same.

    You should ignore case when comparing words, i.e. a is the same as A, b is the same as B, etc.

    Sample Input

    4
    TomMarvoloRiddle IamLordVoldemort
    stop pots
    abbc bac
    InternetAnagramServer IRearrangementServant

    Sample Output

    Yes
    Yes
    No
    Yes

    HINT

    题意

    题解:

    傻逼题

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define test freopen("test.txt","r",stdin)  
    #define maxn 200000
    #define mod 10007
    #define eps 1e-9
    int Num;
    char CH[20];
    const int inf=0x3f3f3f3f;
    const ll infll = 0x3f3f3f3f3f3f3f3fLL;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    inline void P(int x)
    {
        Num=0;if(!x){putchar('0');puts("");return;}
        while(x>0)CH[++Num]=x%10,x/=10;
        while(Num)putchar(CH[Num--]+48);
        puts("");
    }
    //**************************************************************************************
    
    string s1,s2;
    map<char,int> H;
    int main()
    {  
        //test;
        int t=read();
        while(t--)
        {
            H.clear();
            cin>>s1>>s2;
            for(int i=0;i<s1.size();i++)
            {
                if(s1[i]>='A'&&s1[i]<='Z')
                    s1[i]=s1[i]-'A'+'a';
                H[s1[i]]++;
            }
            int flag=1;
            if(s1.size()!=s2.size())
                flag=0;
            for(int j=0;j<s2.size();j++)
            {
                if(s2[j]>='A'&&s2[j]<='Z')
                    s2[j]=s2[j]-'A'+'a';
                if(!flag)
                    break;
                if(!H[s2[j]])
                {
                    flag=0;
                    break;
                }
                else
                    H[s2[j]]--;
            }
            if(flag)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
  • 相关阅读:
    Android开源项目发现---ImageView 篇(持续更新)
    Android开源项目发现---GridView 篇(持续更新)
    python的setup.py文件
    版本控制系统git
    python如何调用c编译好可执行程序
    Python特殊语法:filter、map、reduce、lambda [转]
    Apache+Mysql+PHP 套件
    django开发环境搭建(参考流程)
    C++ GUI Qt4编程-创建自定义窗口部件
    Qt学习笔记-Widget布局管理
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4545189.html
Copyright © 2011-2022 走看看