首页 > 其他分享 >挑战用 UU 的码风写一篇代码

挑战用 UU 的码风写一篇代码

时间:2023-10-05 19:23:13浏览次数:49  
标签:std typedef 一篇 UU tparam param 码风 T1 mod

本文运用了 UU 最新发布的UU命名空间完成,代码内容为今日模拟赛 T3。

提交记录

代码示例
#include <bits/stdc++.h>

namespace User_Unauthorized {
    /**
     * @brief This is a header file for competitive programming.
     * @author User-Unauthorized
     * @version 1.0.0
     * @date 2023-10-5
     */

    typedef long long valueType;
    typedef std::vector<valueType> ValueVector;
    typedef std::vector<ValueVector> ValueMatrix;
    typedef std::vector<ValueMatrix> ValueCube;
    typedef std::map<valueType, valueType> ValueMap;
    typedef std::set<valueType> ValueSet;
    typedef std::pair<valueType, valueType> ValuePair;
    typedef std::vector<ValuePair> PairVector;
    typedef std::vector<PairVector> PairMatrix;
    typedef std::vector<PairMatrix> PairCube;
    typedef std::map<ValuePair, valueType> PairMap;
    typedef std::set<ValuePair> PairSet;
    typedef std::vector<bool> bitset;
    typedef std::vector<bitset> BitMatrix;
    typedef std::vector<BitMatrix> BitCube;
    typedef long double realType;
    typedef std::vector<realType> RealVector;
    typedef std::vector<RealVector> RealMatrix;
    typedef std::vector<RealMatrix> RealCube;
    typedef std::pair<realType, realType> RealPair;
    typedef std::vector<RealPair> RealPairVector;
    typedef std::vector<RealPairVector> RealPairMatrix;
    typedef std::vector<RealPairMatrix> RealPairCube;
    typedef std::mt19937 Engine;
    typedef std::uniform_int_distribution<valueType> Distribution;
    typedef unsigned long long hashType;
    typedef std::vector<hashType> HashVector;
    typedef std::vector<HashVector> HashMatrix;
    typedef std::vector<HashMatrix> HashCube;
    typedef std::map<hashType, valueType> HashMap;
    typedef std::set<hashType> HashSet;

    namespace ModOper {
        /**
         * @brief This is a set of functions for fast processing of operations under the meaning of taking modulus in competitive programming.
         * @author User-Unauthorized
         * @version 1.0.0
         * @warning Please note that the parameter types of these functions must be integer types, otherwise a compilation error will occur.
         * */

        valueType MOD; // mod value

        /**
         * @brief This is a macro for whether to ensure that the parameters passed in are integers in the range [0, MOD), if it cannot be guaranteed, the value of this macro should be true, otherwise unexpected results may occur.
         */
#define ModOperSafeModOption false

        /**
         * @brief This function can increase the value of a by b.
         * @tparam T1
         * @tparam T2
         * @tparam T3
         * @param a
         * @param b
         * @param mod
         */
        template <typename T1, typename T2, typename T3 = valueType>
        void Inc(T1 &a, T2 b, const T3 &mod = MOD) {
#if ModOperSafeModOption
            a %= mod;
            b %= mod;

            if (a < 0)
                a += mod;

            if (b < 0)
                b += mod;
#endif // ModOperSafeModOption

            a = a + b;

            if (a >= mod)
                a -= mod;
        }

        /**
         * @brief This function can decrease the value of a by b.
         * @tparam T1
         * @tparam T2
         * @tparam T3
         * @param a
         * @param b
         * @param mod
         */
        template <typename T1, typename T2, typename T3 = valueType>
        void Dec(T1 &a, T2 b, const T3 &mod = MOD) {
#if ModOperSafeModOption
            a %= mod;
            b %= mod;

            if (a < 0)
                a += mod;

            if (b < 0)
                b += mod;
#endif // ModOperSafeModOption

            a = a - b;

            if (a < 0)
                a += mod;
        }

        /**
         * @brief This function can calculate the sum of a and b.
         * @tparam T1
         * @tparam T2
         * @tparam T3
         * @param a
         * @param b
         * @param mod
         * @return T1
         */
        template <typename T1, typename T2, typename T3 = valueType>
        T1 sum(T1 a, T2 b, const T3 &mod = MOD) {
#if ModOperSafeModOption
            a %= mod;
            b %= mod;

            if (a < 0)
                a += mod;

            if (b < 0)
                b += mod;
#endif // ModOperSafeModOption

            return a + b >= mod ? a + b - mod : a + b;
        }

        /**
         * @brief This function can calculate the difference of a and b.
         * @tparam T1
         * @tparam T2
         * @tparam T3
         * @param a
         * @param b
         * @param mod
         * @return T1
         */
        template <typename T1, typename T2, typename T3 = valueType>
        T1 sub(T1 a, T2 b, const T3 &mod = MOD) {
#if ModOperSafeModOption
            a %= mod;
            b %= mod;

            if (a < 0)
                a += mod;

            if (b < 0)
                b += mod;
#endif // ModOperSafeModOption

            return a - b < 0 ? a - b + mod : a - b;
        }

        /**
         * @brief This function can calculate the product of a and b.
         * @tparam T1
         * @tparam T2
         * @tparam T3
         * @param a
         * @param b
         * @param mod
         * @return T1
         */
        template <typename T1, typename T2, typename T3 = valueType>
        T1 mul(T1 a, T2 b, const T3 &mod = MOD) {
#if ModOperSafeModOption
            a %= mod;
            b %= mod;

            if (a < 0)
                a += mod;

            if (b < 0)
                b += mod;
#endif // ModOperSafeModOption

            return (long long)a * b % mod;
        }

        /**
         * @brief This function can make the value of a multiply b.
         * @tparam T1
         * @tparam T2
         * @tparam T3
         * @param a
         * @param b
         * @param mod
         * @return T1
         */
        template <typename T1, typename T2, typename T3 = valueType>
        void Mul(T1 &a, T2 b, const T3 &mod = MOD) {
#if ModOperSafeModOption
            a %= mod;
            b %= mod;

            if (a < 0)
                a += mod;

            if (b < 0)
                b += mod;
#endif // ModOperSafeModOption

            a = (long long)a * b % mod;
        }

        /**
         * @brief This function can calculate the b-th power of a, and the time complexity is log b.
         * @tparam T1
         * @tparam T2
         * @tparam T3
         * @param a
         * @param b
         * @param mod
         * @return T1
         */
        template <typename T1, typename T2, typename T3 = valueType>
        T1 pow(T1 a, T2 b, const T3 &mod = MOD) {
#if ModOperSafeModOption
            a %= mod;
            b %= mod - 1;

            if (a < 0)
                a += mod;

            if (b < 0)
                b += mod - 1;
#endif // ModOperSafeModOption

            T1 result = 1;

            while (b > 0) {
                if (b & 1)
                    Mul(result, a, mod);

                Mul(a, a, mod);
                b = b >> 1;
            }

            return result;
        }
    } // namespace ModOper
} // namespace User_Unauthorized

using namespace User_Unauthorized;

int main(int argv, char *argc[]) {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    valueType N, M, K;

    std::cin >> N >> M >> K;

    ValueVector ans(N + 1, 0), B(N + 1, 0);
    valueType tot(0);

    for (valueType i = 1; i <= N; i++) {
        valueType x;

        std::cin >> x;

        if (B[tot] > x)
            ans[i + M - 1] = x;
        else
            B[++tot] = x;
    }

    valueType position(std::max(0ll, tot - 20)), len = tot - position;

    ValueVector Ans(N + 1, 0), num(N + 1, 0);

    for (valueType i = 1; i <= position; i++)
        Ans[i] = i;

    for (valueType i = 1; i <= len; i++)
        num[i] = std::min(i + position + M - 1, tot) - position;

    for (valueType i = 1; i <= len; i++) {
        for (valueType j = 1; j <= len; j++)
            num[j]--;

        for (valueType j = 1; j <= len; j++) {
            if (num[j] < 0)
                continue;

            valueType sum = 0, now = 1;

            for (valueType k = 1; k <= len; k++) {
                if (num[k] < 0 || k == j)
                    continue;

                now *= num[k] - sum;

                sum++;

                if (now >= K)
                    break;
            }

            if (now >= K) {
                Ans[i + position] = j + position;
                num[j] = -1;
                break;
            }

            K -= now;
        }
    }

    tot = 0;

    for (valueType i = 1; i <= N; i++) {
        if (ans[i])
            std::cout << ans[i] << " ";
        else
            std::cout << B[Ans[++tot]] << " ";
    }
    return 0;
}

标签:std,typedef,一篇,UU,tparam,param,码风,T1,mod
From: https://www.cnblogs.com/baijian0212/p/17743774.html

相关文章

  • BUUOJ[ACTF2020 新生赛]Include 1
    原理文件包含伪协议的利用解题过程靶场进入发现一个超链接,点了一下发现跳转到了flag.php文件传递了参数file=flag.php。猜测应该是文件包含。文件包含读取文件源码要想到伪协议了。--要多补补了payload:?file=php://filter/read=convert.base64-encode/resource=flag.php......
  • BUUOJ[极客大挑战 2019]Havefun 1
    原理url参数的传递页面原代码的查看解题过程进入靶场没看到什么有用的东西,那就得看页面源代码了,一般都有提示果然,让我们传递值为dog的cat参数,试一下payload:?cat=dog爆出flag......
  • BUUOJ[极客大挑战 2019]EasySQL 1
    原理涉及sql注入的or万能登录解题过程看到题目名字,应该就是要用到sql注入了,进入网页,看到了要登陆,我一开始想到要爆破(呃呃呃)。要用sql去登录的话,就要想到or万能登录了payload:1'or1=1#账号密码都是字符型的注入,因此有时候需要尝试一下'和"接着就爆出flag了另外,我在url......
  • c/c++获取uuid
    c/c++标准库中没有自带的uuid工具函数/类,可以使用三方库libuuid,boost,或者手工实现,如下:[zjh@hs-10-20-xxxlib]$sudoyuminstalllibuuid-devel[sudo]passwordforzjh:Loadedplugins:fastestmirror,langpacksLoadingmirrorspeedsfromcachedhostfilebase......
  • 一篇文章让你理解:什么是Spring???
    背景市场上,随便一个Java工程师的招牌要求上,都可以看到SSM、Spring、SpringMVC...类似字样。这玩意到底是个啥?这是中邮消费招聘的岗位要求,可以看到第3点:3、熟悉Struts/Spring/SpringMVC/...对于Java开发这来说,Spring就像是我们吃饭要用的筷子一样,有着很强的实用性。所以,我们......
  • 我的第一篇博客园随笔
    终于盼望着国庆假期的到来了,晚上闲来无事,打算完成以下老师的小任务--完成自己的博客设计。可能是CSDN的大众流行,加上现在程序员网站如雨后春笋般的出现,再加上个人博客页面越来越多,我对“博客园”的印象其实并不是很深刻,当我现在敲这篇文章,会有一种在2007年用诺基亚手机发短信......
  • uuid
    title:UUID简介tags:UUIDcategories:干垃圾keywords:UUIDdescription:UUID简介top:repost:hot:others:date:2020-01-2210:11:15{%notesuccessno-icon%}UUID简介(PHP为例)介绍名称:UniversallyUniqueIdentifier(通用唯一标识符)简介UUID是一串全球......
  • 第一篇
    写了这么多年代码,也做了几年管理。突然间想记录点东西,可能是一些人生感悟,遇到的技术问题,学习的新内容等等,也会开源一些代码,希望能够帮助到别人。 为什么选择博客园呢?1.写过C#代码的应该浏览过博客园,这么干净的园子不多了。2.希望博客园坚持下去,跟我们这些码农一样,因为热爱......
  • 第一篇博客
    回顾————我的初心 选择大数据这个专业很巧合,当时处于填报志愿期间,还不知道有大数据这个专业,我想选一个和计算机有关,能收集互联网上大量的数据的专业,在一次参观学校中,第一次认识到了大数据这个专业,很符合我想要的,于是毫不犹豫地选择了大数据这个专业,我希望以后能通过大数据这......
  • Buuctf——[GXYCTF2019]BabySQli
    本题目是一道联合注入进入页面后发现只有一个登录框。知识点unionselect联合查询union拼接的两个查询语句查询字段数必须一样多当其中一个查询结果为空时,不影响另外一个语句的查询结果联合注入核心是使用拼接的select语句同时使原查询语句结果为空来覆盖原查询结果,从而实......