Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

300题留念,1A,留下源码

Posted by vjubge4 at 2019-04-21 10:31:06 on Problem 2159
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char C[101];
char M[101];
int Ctr1[27];
int Ctr2[27];

int main(){
    scanf("%s %s", C, M);
    int L = strlen(C);
    memset(Ctr1, 0, sizeof(Ctr1));
    memset(Ctr2, 0, sizeof(Ctr2));
    for (int i = 0; i < L; ++i) {
        Ctr1[C[i] - 'A'] ++;
        Ctr2[M[i] - 'A'] ++;
    }
    sort(Ctr1, Ctr1 + 27);
    sort(Ctr2, Ctr2 + 27);
    bool flag = true;
    for (int i = 0; i < 27; ++i) {
        if (Ctr1[i] != Ctr2[i]){
            flag = false;
            break;
        }
    }
    if (flag){
        printf("YES\n");
    } else{
        printf("NO\n");
    }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator