zoukankan      html  css  js  c++  java
  • UVa LA 3213

    题目

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1214


    题意

    问字符串a能否是字符串b经过某种替换+移位密码的密文

    思路

    明显,计数对的上就行

    刘书题目描述不全面

    代码

    #include <algorithm>
    #include <cassert>
    #include <cmath>
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <map>
    #include <queue>
    #include <set>
    #include <string>
    #include <tuple>
    #define LOCAL_DEBUG
    using namespace std;
    typedef pair<int, int> MyPair;
    int cnta[256];
    int cntb[256];
    
    bool judge(string a, string b) {
        memset(cnta, 0, sizeof cnta);
        memset(cntb, 0, sizeof cntb);
        for (int i = 0; i < a.size(); i++) {
            cnta[a[i]]++;
            cntb[b[i]]++;
        }
        sort(cnta, cnta + 256);
        sort(cntb, cntb + 256);
        for (int i = 0; i < 256; i++) {
            if (cnta[i] != cntb[i])return false;
        }
        return true;
    }
    
    int main() {
    #ifdef LOCAL_DEBUG
        freopen("C:\Users\Iris\source\repos\ACM\ACM\input.txt", "r", stdin);
        //freopen("C:\Users\Iris\source\repos\ACM\ACM\output.txt", "w", stdout);
    #endif // LOCAL_DEBUG
        int T;
        string a, b;
        for (int ti = 1;cin>>a>>b; ti++) {
            if (judge(a, b))puts("YES");
            else puts("NO");
        }
    
        return 0;
    }
    View Code
  • 相关阅读:
    面试十题(4)
    TS中给接口指定的成员?
    TS中定义泛型接口的两种方式
    ts中泛型的使用
    ts中类的属性的封装
    ts中接口的使用
    自定义hook的步骤
    react中如何使用useReducer?
    react中useContext的使用
    react 中useRef的作用
  • 原文地址:https://www.cnblogs.com/xuesu/p/10457660.html
Copyright © 2011-2022 走看看