Ancient Cipher 古代密码

版权声明:若有转载,请标注原博客地址!谢谢 https://blog.csdn.net/DreamTrue1101/article/details/84064383

题目链接:Ancient Cipher

 UVA - 1339 

题意:给出两个长度相等的大写字母序列,问能否从一个序列映射到另一个序列(序列长度 <= 100)

代码实现:

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define inf 1e6+5
using namespace std;
typedef long long ll;
char arr[1000],brr[1000];
int main()
{
    while(~scanf("%s%s",arr,brr))
    {
        bool f=true;
        int arr1[26]={0},brr1[26]={0};
        for(int i=0;i<strlen(arr);i++)
        {
            arr1[arr[i]-'A']++;
            brr1[brr[i]-'A']++;
        }
        sort(arr1,arr1+26);
        sort(brr1,brr1+26);
        for(int i=0;i<26;i++)
        {
            if(arr1[i]!=brr1[i])
            {
                f=false;
                break;
            }
        }
        if(f==true)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}
 

猜你喜欢

转载自blog.csdn.net/DreamTrue1101/article/details/84064383