首页 > 其他 > 详细

POJ 2159 Ancient Cipher

时间:2015-09-15 23:13:13      阅读:230      评论:0      收藏:0      [点我收藏+]

题意:被题意杀了……orz……那个替换根本就不是ASCII码加几……就是随机的换成另一个字符……

 

解法:只要统计每个字母的出现次数,然后把数组排序看相不相同就行了……

 

代码:

#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;

int main()
{
    string s1, s2;
    while(cin >> s1 >> s2)
    {
        vector <int> v1, v2;
        for(int i = 0; i < 26; i++)
        {
            v1.push_back(0);
            v2.push_back(0);
        }
        for(int i = 0; i < s1.size(); i++)
        {
            v1[s1[i] - ‘A‘]++;
            v2[s2[i] - ‘A‘]++;
        }
        sort(v1.begin(), v1.end());
        sort(v2.begin(), v2.end());
        if(v1 == v2) puts("YES");
        else puts("NO");
    }
    return 0;
}

  

POJ 2159 Ancient Cipher

原文:http://www.cnblogs.com/Apro/p/4811644.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!