当前位置: 代码迷 >> 综合 >> LA 3213 Ancient Cipher -
  详细解决方案

LA 3213 Ancient Cipher -

热度:119   发布时间:2023-09-23 05:23:58.0

题目地址:http://vjudge.net/problem/UVALive-3213

是比较每个字母出现的频率

数组越位一位,导致一直WA...

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<=(b);++i)
#define REPD(i,a,b) for(int i=a;i>=(b);--i)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
int Num1[26],Num2[26];
char s1[100+3],s2[100+3];
int main(int argc, char const *argv[])
{while(scanf("%s%s",s1,s2)==2){memset(Num1,0,sizeof(Num1));memset(Num2,0,sizeof(Num2));for(int i=0;s1[i];++i) Num1[s1[i]-'A']++,Num2[s2[i]-'A']++;sort(Num1,Num1+26); sort(Num2,Num2+26);bool ok=true;REP(i,0,25) if(Num1[i]!=Num2[i]) {ok=false;break;}printf("%s\n", ok?"YES":"NO");}return 0;
}