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

Re:C++有毒,用G++过题

Posted by ALLACS at 2017-09-29 20:26:03 on Problem 2159
In Reply To:C++有毒,用G++过题 Posted by:ALLACS at 2017-09-29 20:20:01
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const char *s="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int maxn=26;
int a[maxn],b[maxn];
string maze;
string org;
int main()
{
    cin>>maze>>org;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    if(maze.length()!=org.length()) printf("NO\n");
    else {
                for(int i=0;i<maxn;i++)
                {
                    for(int j=0;j<org.length();j++)
                    {
                        if(s[i]==org[j]) a[i]++;
                        if(s[i]==maze[j]) b[i]++;
                    }
                }
                sort(a,a+maxn);
                sort(b,b+maxn);
                int t=1;
                for(int i=0;i<maxn;i++)
                     if(a[i]!=b[i]) {
                                       t=0;
                                       break;
                                      }
                if(t) printf("YES\n");
                else printf("NO\n");
           }
    return 0;
}

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