Codeforces CodeTON Round 8(Div.1 + Div.2) A~E

5个4000比特大状态置换算法的设计与分析 下面是 5 个概念性、实验性的 4000 位可逆置换设计。它们都保证是双射,但未经过密码分析,不可直接用于生产系统。风格分别覆盖:三维 SPN、Feistel、可逆元胞自动机、ARX、宽轨迹/Keccak 式结构。 这 5 个设计分别代表了 SPN、Feistel、元胞自动机、ARX、宽轨迹 Keccak 五种不同风格,覆盖了主流大状态置换的构造思路。再次强调:它们只是实验性概念,若要用于实际协议,必须经过严格安全性分析。 阅读详情

A. Farmer John’s Challenge (模拟)

题意:

构造一个长度为nnn的数组,将这些数组围成一个圈(顺时针)从任意一个位置打开,有且仅有 kkk个非降序排列的数组。

分析:

k=1k=1k=1时,升序输出1−n1-n1−n,n=kn=kn=k时,全111即可。其他情况都是−1-1−1。

代码:

#include <bits/stdc++.h>

using namespace std;
const int mod = 1e9 + 7;

int main() {
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin >> n >> k;
        if (k == 1) {
            for (int i = 1; i <= n; i++)
                cout << i << " ";
            cout << endl;
        } else if (n == k) {
            for (int i = 1; i <= n; i++)
                cout << 1 << " ";
            cout << endl;
        } else
            cout << -1 << endl;
    }
    return 0;
}

B.Bessie and MEX (思维)

题意:

给出一个长度为 nnn 的数组 aaa ,根据 aaa 构造出一个排列 ppp 。数组 aaa 的构造使得 aia_iai​ = MEX(p1,p2,…,pi)−pi\texttt{MEX}(p_1, p_2, \ldots, p_i) - p_iMEX(p1​,p2​,…,pi​)−pi​ ,其中数组的 MEX\texttt{MEX}MEX 是该数组中没有出现的最小非负整数。

分析:

ai>0a_i>0ai​>0,填入当前的最小值,同时更新最小值,ai<0a_i<0ai​<0时,mexmexmex没有更新,加上绝对值即可。

代码:

#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int a[N], p[N];

int main() {
    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        int minval = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] > 0) {
                p[i] = minval;
                minval = a[i] + minval;
            } else {
                p[i] = minval - a[i];
            }
        }
        for (int i = 1; i <= n; i++)
            cout << p[i] << " ";
        cout << endl;
    }
    return 0;
}

C1. Bessie’s Birthday Cake (Easy Version) (数学)

题意:

贝西从她最好的朋友埃尔西那里收到了一个生日蛋糕,它是一个边长为 nnn 的正多边形。蛋糕的顶点按顺时针方向从 111 排列到 nnn 。你和贝西将选择其中的一些顶点在蛋糕上切出不相交的对角线。换句话说,对角线的端点必须是所选顶点的一部分。
为了保持一致性,贝西只想分发三角形的蛋糕。蛋糕块的大小并不重要,整个蛋糕也不一定要分成三角形(蛋糕中可以有其他形状,但不计算在内)。
贝西已经选择了 xxx 个顶点,可以用来组成对角线。她希望你选择的其他顶点不超过yyy ,这样她能分出的三角形蛋糕的数量就能达到最大。
贝西最多能分出多少块三角形蛋糕?
此题保证y=0y=0y=0

分析:

假设对答案有贡献的点叫有效点,可以发现如果两个点之间正好只有一个点,那么这个点也是有效的,答案是总的有效点数减222.

代码:

#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int a[N];

int main() {
    int T;
    cin >> T;
    while (T--) {
        int n, x, y, cnt;
        cin >> n >> x >> y;
        cnt = x - 2;
        for (int i = 1; i <= x; i++)
            cin >> a[i];
        sort(a + 1, a + x + 1);
        for (int i = 1; i < x; i++) {
            if (a[i] + 1 == a[i + 1] - 1) {
                cnt++;
            }
        }
        if (a[x] == n - 1 && a[1] == 1)
            cnt++;
        else if (a[x] == n && a[1] == 2)
            cnt++;
        cout << cnt << endl;
    }
    return 0;
}

C2.Bessie’s Birthday Cake (Hard Version) (数学)

题意:

贝西从她最好的朋友埃尔西那里收到了一个生日蛋糕,它是一个边长为 nnn 的正多边形。蛋糕的顶点按顺时针方向从 111 排列到 nnn 。你和贝西将选择其中的一些顶点在蛋糕上切出不相交的对角线。换句话说,对角线的端点必须是所选顶点的一部分。
为了保持一致性,贝西只想分发三角形的蛋糕。蛋糕块的大小并不重要,整个蛋糕也不一定要分成三角形(蛋糕中可以有其他形状,但不计算在内)。
贝西已经选择了 xxx 个顶点,可以用来组成对角线。她希望你选择的其他顶点不超过yyy ,这样她能分出的三角形蛋糕的数量就能达到最大。
贝西最多能分出多少块三角形蛋糕?

分析:

通过简单版本发现,每次操作可以让有效点数加222,但是如果一段只剩下333个点,那么可以一次性操作让有效点数加333。同时发现奇数间隔可以获得的贡献更大,所以优先操作间距短的奇数长度区间间隔,再操作偶数区间间隔。

代码:

#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;

int main() {
    int T;
    cin >> T;
    while (T--) {
        int n, x, y;
        cin >> n >> x >> y;
        vector<int> a(x);
        for (int i = 0; i < x; i++)
            cin >> a[i];
        sort(a.begin(), a.end());
        int sum = x;
        vector<int> tmp[2];
        for (int i = 0; i < x; i++) {
            int len = a[(i + 1) % x] - a[i] - 1;
            if (len < 0)
                len += n;
            if (len == 1)
                sum += 1;
            if (len > 1) {
                tmp[len % 2].push_back(len);
            }
        }
        for (int i = 1; i >= 0; i--) {
            sort(tmp[i].begin(), tmp[i].end());
            for (auto u: tmp[i]) {
                if (u % 2 == 1) {
                    int num2 = (u - 3) / 2;
                    int t = min(y, num2);
                    y -= t;
                    sum += t * 2;
                    int num3 = 1;
                    t = min(y, num3);
                    y -= t;
                    sum += t * 3;
                } else {
                    int num2 = u / 2;
                    int t = min(y, num2);
                    y -= t;
                    sum += t * 2;
                }
            }
        }
        cout << sum - 2 << endl;
    }
    return 0;
}

D.Learning to Paint (dp)

题意:

艾尔西正在学习如何绘画。她的画布上有 nnn 个单元格,编号从 111 到 nnn ,她可以画任何(可能是空)单元格子集。
艾尔西有一个二维数组 aaa ,她将用这个数组来评估绘画作品。假设一幅画中绘画单元格的最大连续间隔为 [l1,r1],[l2,r2],…,[lx,rx][l_1,r_1],[l_2,r_2],\ldots,[l_x,r_x][l1​,r1​],[l2​,r2​],…,[lx​,rx​] 。这幅画的美丽值是所有 1≤i≤x1 \le i \le x1≤i≤x 中 ali,ria_{l_i,r_i}ali​,ri​​ 的总和。
有 2n2^n2n 种方法可以绘制条形图。请帮助艾尔西找出在所有这些方法中,前kkk大的美丽值。这kkk种美丽值可以相同,但要保证至少有kkk种画法。

分析:

fff表示使用前iii个位置的前kkk大和,但是位置iii不一定要涂色。ggg表示使用前iii个位置且以iii开头的前kkk大和,保证位置iii为涂色开头。即f[i][j]f[i][j]f[i][j]表示使用前iii个位置,第jjj大的和。g[i][j]g[i][j]g[i][j]表示 使用前iii个位置,iii涂色 且i−1i-1i−1不涂色 第jjj大的和。
维护f[i]f[i]f[i],可以用优先队列,从 g[1...i]g[1...i]g[1...i]转移,同时维护g[1...i]g[1...i]g[1...i]最大的值,取前kkk个用于更新f[i]f[i]f[i]。在更新g[i+1]g[i+1]g[i+1]时,因为iii不涂色,以i−1i-1i−1及前面的位置结尾都可,因此就是 g[i+1]=f[i−1];g[i+1]=f[i-1];g[i+1]=f[i−1];

代码:

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
#define PII pair<LL, LL>
const int mod = 1e9 + 7;
const int INF = 1e9;

int main() {
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin >> n >> k;
        vector<vector<int>> a(n + 1, vector<int>(n + 1));
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                cin >> a[i][j];
            }
        }
        vector<vector<int>> f(n + 1, vector<int>(k, -INF));
        vector<vector<int>> g(n + 2, vector<int>(k, -INF));
        g[1][0] = 0;
        f[0][0] = 0;
        vector<int> c(k);
        vector<int> p(n + 1);
        for (int i = 1; i <= n; i++) {
            priority_queue<PII > tmp;
            for (int j = 1; j <= i; j++) {
                tmp.push({g[j][0] + a[j][i], j});
                p[j] = 0;
            }
            for (int t = 0; t < k; t++) {
                auto [s, j] = tmp.top();
                tmp.pop();
                f[i][t] = s;
                p[j]++;
                tmp.push({g[j][p[j]] + a[j][i], j});
            }
            int l = 0, r = 0;
            for (int t = 0; t < k; t++) {
                c[t] = max(f[i - 1][l], f[i][r]);
                if (f[i - 1][l] > f[i][r])
                    l++;
                else
                    r++;
            }
            f[i] = c;
            g[i + 1] = f[i - 1];
        }

        for (int i = 0; i < k; i++) {
            cout << f[n][i] << " ";
        }
        cout << endl;
    }
    return 0;
}

E.Farm Game (组合数)

题意:

农夫 NhojNhojNhoj 带着他的奶牛来到农夫 JohnJohnJohn 的农场玩游戏!农夫约翰的农场可以用一条在 000 和 l+1l + 1l+1 点有墙的数线来模拟。农场里有 2n2n2n 头奶牛,其中 nnn 头属于 FJFJFJ,另外 nnn 头属于 FNFNFN。他们把每头牛都放在一个不同的点上,FJFJFJ 的牛和 FNFNFN 的牛都不相邻。如果两头奶牛之间没有其他奶牛,它们就是相邻的。
在一次下棋中,农夫选择了 kkk(1≤k≤n)(1 \leq k \leq n)(1≤k≤n) 和一个方向(左或右)。然后,农夫选择 kkk 头奶牛,并将它们朝所选方向移动一个位置。农场主不能将自己的奶牛移动到墙上或其他农场主的奶牛上。如果一位农夫不能移动任何奶牛,那么他就输了。FJFJFJ先开始游戏,进行第一个回合。
给定 lll 和 nnn ,求如果两个农夫都以最佳方式下棋,农夫约翰可能获胜的棋局配置数。对局可能无限期地进行下去,在这种情况下没有农民获胜。如果有任何 iii 与 aia_iai​ 或 bib_ibi​ 不同,则该配置与另一种配置不同。输出答案,请将答案对998244353998244353998244353取模。

分析:

首先发现a[i]a[i]a[i]在 b[i]b[i]b[i]前面 和 a[i]a[i]a[i]在 b[i]b[i]b[i]后面这两种情况实际是一样,只需要计算其中一种情况,最后答案乘222即可。
如果 b[i]−a[i]−1b[i]-a[i]-1b[i]−a[i]−1 不全为偶数,那么就是 FJFJFJ 必胜。因为全为偶数是必败态,又由于kkk至少为111,如果全是偶数,FJFJFJ 转移一次后 FNFNFN 获得的是必胜态。如果不全是偶数,FJFJFJ 可以转移一次全变成偶数,FNFNFN 获得的就是必败态了。
我们逆向考虑,用总答案数减去全为偶数的情况。总答案数为C(l,2×n)C(l,2\times n)C(l,2×n)。当(b[i]−a[i]−1)(b[i]-a[i]-1)(b[i]−a[i]−1)全为偶数时,考虑空地怎么插在牛之间,(a,b)(a,b)(a,b)内只能插偶数块空地,枚举插入(a,b)(a,b)(a,b)内的空地对的个数为mmm。(a,b)(a,b)(a,b)一共有nnn 组,答案为C(n+m−1,m−1)C(n+m−1,m−1)C(n+m−1,m−1)。
剩下的空地插在(b,a)(b,a)(b,a)和(0,a[0])(0,a[0])(0,a[0]),(b[n],l+1)(b[n],l+1)(b[n],l+1)内,一共n+1n+1n+1组,用同样的方法计算。

代码:

#include <bits/stdc++.h>

using namespace std;
const int N = 1e6 + 5;
const int mod = 998244353;

template<const int T>
struct ModInt {
    const static int mod = T;
    int x;

    ModInt(int x = 0) : x(x % mod) {}

    ModInt(long long x) : x(int(x % mod)) {}

    int val() { return x; }

    ModInt operator+(const ModInt &a) const {
        int x0 = x + a.x;
        return ModInt(x0 < mod ? x0 : x0 - mod);
    }

    ModInt operator-(const ModInt &a) const {
        int x0 = x - a.x;
        return ModInt(x0 < 0 ? x0 + mod : x0);
    }

    ModInt operator*(const ModInt &a) const { return ModInt(1LL * x * a.x % mod); }

    ModInt operator/(const ModInt &a) const { return *this * a.inv(); }

    bool operator==(const ModInt &a) const { return x == a.x; };

    bool operator!=(const ModInt &a) const { return x != a.x; };

    void operator+=(const ModInt &a) {
        x += a.x;
        if (x >= mod)
            x -= mod;
    }

    void operator-=(const ModInt &a) {
        x -= a.x;
        if (x < 0)
            x += mod;
    }

    void operator*=(const ModInt &a) { x = 1LL * x * a.x % mod; }

    void operator/=(const ModInt &a) { *this = *this / a; }

    friend ModInt operator+(int y, const ModInt &a) {
        int x0 = y + a.x;
        return ModInt(x0 < mod ? x0 : x0 - mod);
    }

    friend ModInt operator-(int y, const ModInt &a) {
        int x0 = y - a.x;
        return ModInt(x0 < 0 ? x0 + mod : x0);
    }

    friend ModInt operator*(int y, const ModInt &a) { return ModInt(1LL * y * a.x % mod); }

    friend ModInt operator/(int y, const ModInt &a) { return ModInt(y) / a; }

    friend ostream &operator<<(ostream &os, const ModInt &a) { return os << a.x; }

    friend istream &operator>>(istream &is, ModInt &t) { return is >> t.x; }

    ModInt pow(int64_t n) const {
        ModInt res(1), mul(x);
        while (n) {
            if (n & 1)
                res *= mul;
            mul *= mul;
            n >>= 1;
        }
        return res;
    }

    ModInt inv() const {
        int a = x, b = mod, u = 1, v = 0;
        while (b) {
            int t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        if (u < 0)
            u += mod;
        return u;
    }
};

using mint = ModInt<mod>;

mint fact[N], invfact[N];

void init() {
    fact[0] = invfact[0] = 1;
    for (int i = 1; i < N; i++)
        fact[i] = fact[i - 1] * i;
    invfact[N - 1] = fact[N - 1].inv();
    for (int i = N - 2; i; i--)
        invfact[i] = invfact[i + 1] * (i + 1);
}

inline mint C(int a, int b) {
    if (a < 0 || b < 0 || a < b)
        return 0;
    return fact[a] * invfact[b] * invfact[a - b];
}

int main() {
    init();
    int t;
    cin >> t;
    while (t--) {
        int l, n;
        cin >> l >> n;
        mint ans = C(l, 2 * n);
        int k = l - 2 * n;
        for (int m = 0; 2 * m <= k; m++) {
            mint res = C(n + m - 1, n - 1);
            res *= C((n + 1) + (k - 2 * m) - 1, (n + 1) - 1);
            ans -= res;
        }
        ans *= 2;
        cout << ans << endl;
    }
    return 0;
}

赛后交流

在比赛结束后,会在交流群中给出比赛题解,同学们可以在赛后查看题解进行补题。

群号: 704572101,赛后大家可以一起交流做题思路,分享做题技巧,欢迎大家的加入。

从零到一:Halcon手眼标定的实战避坑指南 本文详细解析了Halcon手眼标定的完整流程,重点介绍了Eye-in-Hand和Eye-to-Hand两种模式的实操技巧与常见陷阱。通过九点法、N点法等实战案例,提供硬件配置检查、数据采集策略及误差修正方案,帮助开发者提升机械臂与视觉系统的协同精度,适用于工业自动化领域的精准定位与抓取任务。 阅读详情

相关推荐

告别迷茫!手把手教你用Synopsys VC USB VIP搭建验证平台(附UVM分层序列实战解析)

本文详细介绍了如何使用Synopsys VC USB VIP搭建验证平台,并深入解析UVM分层序列的实战应用。通过Step-by-Step的操作指南和关键配置示例,帮助验证工程师高效集成USB VIP,掌握从环境搭建到测试用例开发的全套技能,特别适合处理复杂协议验证的挑战。

weixin_42520573的博客 553

CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes) A~E

A. Good Pairs 题意: 给一个数组,要求在其中选出两个数,满足以下公式 ∣ai−ak∣+∣ak−aj∣=∣ai−aj∣|a_i - a_k| + |a_k - a_j| = |a_i - a_j|∣ai​−ak​∣+∣ak​−aj​∣=∣ai​−aj​∣ i,j为选出的数的下标,对于所以的1≤k≤n1\le k\le n1≤k≤n都满足,输出两数下标。 思路: 刚开始猜了一下选最大和最小的,答案也确实如此,要想左边的式子等于右边的,那么就要把k消掉,很明显把绝对值符号去掉,两个aka_kak​可

m0_51731088的博客 535

Multisim14.3中FPGA接口电路设计:原理图项目应用

深入讲解在multisim14.3环境下构建FPGA接口电路的方法,结合原理图设计与项目实践,展现multisim14.3强大的电路仿真能力,提升数字系统开发效率。

weixin_42578963的博客 1157

CodeTON Round 8 div2 A-C题解

题意:题解:考虑有序数组中把a1移到最后去,如果此时还想是排序状态的话a1一定大于等于an,然而一开始的状态中a1又一定小于等于an,所以如果想要有两个及以上的数组的话a1一定等于an,这样的话a1到an全是一个数,这样排序数组就有n个,倘若a1不等于an,排序状态就有0或1个,所以其实一共就三种情况,分别构造即可。

qq_74534898的博客 1474

【读论文】AI陪伴场景长期记忆(用户画像)解决方案

在长程人机交互中,如何让 AI 记住用户,不再是简单的“检索增强(RAG)”就能解决的问题。传统的向量数据库面临“信息信噪比低”、“人格不一致”以及“随着对话无限增长而崩塌”的困境。MemTensor 团队联合人大提出的Inside Out框架,从认知心理学汲取灵感,提出了一种基于PersonaTree(人格树)的显式记忆进化机制。该方案通过训练一个轻量级的(使用 DeepSeek-R1 蒸馏数据 + GRPO 强化学习),实现了将非结构化对话流实时压缩为结构化树操作(新增|更新|删除)。

kakaZhui的博客 817

oracle p6 破解版下载,Primavera P6项目管理软件 16~17 图文详细安装教程(附下载)

Primavera P6 Professional项目管理软件结合了Oracle和Microsoft SQL Server关系数据库,是一款非常好用且功能强大的综合的项目管理软件(PPM) 解决方案,主要用于土建等方面的施工计划分析,具有进度时间安排与资源控制功能的多用户、多项目系统,支持多层项目分层结构、角色与技能导向的资源安排、记录实际数据、自定义视图以及自定义数据,本文主要为大家图文详细介绍...

weixin_33978451的博客 4912

CodeTON Round 8 (Div. 1 + Div. 2, Rated, Prizes!)做题笔记

做法:判断a[i]的值,大于0直接等于mex,小于0等于mex-a[i];同时用另外一个数组统计是否使用过该mex值,不断更新就行。做法:判断k和n或者1的关系;k==1则输出1就行,k==n就从1输出到n;都不满足就输出-1;题意:构造出满足条件a[i]=mex{p1,....,pi}-p[i]的数组p;题意:构造出满足条件的数组a,否则输出-1。

qq_74193144的博客 1078

RK-XCKU5P RoCEv2 传感器桥工程分析报告

烧入后这块 FPGA 就是一个固定身份(CA:FE:C0:FF:EE:00 / 192.168.0.2 / 无 FEC 100G)的RoCEv2 UC 端点,每秒在 UDP 12267 广播自报家门;对端 CX5 只要关 FEC、配 192.168.0.101 +MTU 4200,就能 ping 通它、用 UDP 8192 读写它的全部寄存器、再按"ECB 旁路交换 QPN/rkey"的方式建立 UC RDMA 通道收发数据。

eloudy的专栏 245

CodeTON Round 8 (Div. 1 + Div. 2) (A~D)

比赛地址:https://codeforces.com/contest/1942。

yaoye222的博客 682

用yolov8训练自己的模型并调取摄像头实时检测,新手小白超友好教程!逻辑梳理,从0开始逐步实操❤

帮新手小白学会用yolov8,包含多篇高质量博客整理

Lhhhhds的博客 2941

基于深度学习的垃圾邮件识别

垃圾邮件的大量存在严重威胁着电子邮件系统的安全和效率。基于深度学习的垃圾邮件识别技术已经成为目前最有效的解决方案之一。本文将详细介绍使用深度学习技术进行垃圾邮件识别的方法,并提供相应的代码实现。 随着电子邮件的广泛应用,垃圾邮件的数量不断增加,传统的规则和统计方法已经无法满足对垃圾邮件进行准确识别的需求。深度学习技术以其强大的模式识别能力和自动特征提取能力成为解决垃圾邮件识别难题的有效工具。

一键难忘的博客 1093

Codefores CodeTON Round 1 B题

Codefores CodeTON Round 1 B题

m0_64045085的博客 392

9.16华为OD机试真题 新系统 - 统计特殊数字 (Java/Py/C/C++/Js/Go)

9.16华为OD机试真题 新系统 - 统计特殊数字 (Java/Py/C/C++/Js/Go)

算法大师! 758

CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) E题

处理方法:询问vi时,将vi+n,就变成了vi>=i问题,需要查询区间(i,vi+n),那么我们也需要对[n+1,2*n]区间进行维护,维护影响跳过次数的点。进行维护时,考虑影响跳过次数的点,可以发现点是满足该点目标节点在该点右侧,即某一点,i属于[n+1,2*n],v[i]+n >= i。对于i到vi的路径上,假如某个点可以跳过,那么这个点一定初始位置j>i,否则该点一直在i点左侧,无法被i点跳过;最后该点的vj也需要>=j,否则该点无法在i跳到vi之前,跳到vj,对于vi做出贡献。

wang_wins的博客 496

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces 2026上半年赛事深度复盘:从比赛筛选到高效训练指南

在算法竞赛领域,系统性复盘是提升实力的核心。其原理在于通过分析大量比赛数据,识别高质量题目与有效训练路径,从而将有限时间价值最大化。对于Codeforces这类高频赛事平台,选手常面临“打哪些比赛、复盘哪些题”的困惑。本文基于2026年上半年超过60场常规Round的实战数据,从题目质量、难度曲线、出题人风格等维度进行横向对比,旨在解决信息筛选与价值判断问题。通过建立难度坐标系和规划个人训练路径,帮助不同Rating区间的选手识别“信号”与“噪音”,高效利用比赛资源,洞察出题趋势,实现针对性突破。

weixin_33857230的博客 435

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Codeforces LATOKEN Round 1 (Div. 1 + Div. 2)

B. Histogram Ugliness time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Little Dormi received a histogram with n bars of height a1,a2,…,an for Christmas. However, the more he played with his new histo

JackerVJ的博客 246

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Farmer John‘s Challenge(CodeTON Round 8)

【代码】Farmer John‘s Challenge(CodeTON Round 8)

GordrnGhost的博客 204

视频隐私脱敏工程化:CSRT/KCF追踪算法在本地推理中的实现与边界

在短视频内容合规审查中,动态遮挡(Dynamic Masking)是高频且高耗时的环节。传统手动关键帧打码不仅效率低下,且在目标快速移动或遮挡时极易出现遮罩漂移。本文从计算机视觉工程角度,解析基于CSRT与KCF算法的目标追踪方案在视频隐私处理中的技术路径、性能权衡及落地实践。

Mysssone的博客 201

【算法拾光】链表 哈希表|K个一组翻转链表 + 两数之和

K个一组翻转链表需分段反转,借助哑节点与前驱指针维护连接,避免断链;两数之和利用哈希表实现O(1)查找,空间换时间,高效定位目标组合。前者考察链表指针操作,后者聚焦映射关系构建,均为面试高频题。

wuqingyigexiaoba的博客 309

排序算法深度笔记(下):非比较类排序的线性突破与工程边界

排序算法时间复杂度额外空间复杂度稳定性是否基于比较选择排序O(N^2)(O(1))不稳定是冒泡排序O(N^2)(O(1))稳定是插入排序O(N^2)(O(1))稳定是归并排序O(N\log N)(O(N))稳定是快速排序O(N\log N)O(log N)不稳定是堆排序O(N\log N)O(1)不稳定是计数排序(O(N + M))O(M))稳定否基数排序O(N)稳定否桶排序平均O(N) / 最坏O(N^2)

2401_87069538的博客 571

算法日常・每日刷题--<动态规划>42

本题为“不相交的线”,与最长公共子序列问题相似。使用动态规划求解:定义 dp[i][j] 表示 nums1[0:i] 与 nums2[0:j] 的最大不相交连线数。若元素相等,则继承左上值加1;否则取上方或左方最大值。最终返回 dp[m][n],即两数组的最大不相交连线数。时间复杂度 O(mn),空间复杂度 O(mn)。

2503_92261635的博客 20

C语言程序设计题|有序数组插入数字冒泡排序

题目要求将一个数插入有序数组末尾,并用冒泡排序实现整体升序。代码先将输入数存入数组最后位置,再通过双重循环进行冒泡排序,每轮将较大元素向后移动,最终输出11个升序元素。该方法虽时间复杂度为O(n²),但符合题目要求,逻辑清晰,适合初学者理解排序原理。

2301_81429079的博客 748

【算法拾光】模拟|外观数列 + 数青蛙

本文总结两道模拟题解法:外观数列通过迭代统计连续数字个数生成下一项,关键在于处理末尾字符;数青蛙则模拟青蛙叫声“croak”状态转移,维护各阶段青蛙数量,记录最大并发数并确保全部完成。共性在于严格遵循流程、细致处理边界与非法情况,锻炼字符串遍历与状态管理能力。

wuqingyigexiaoba的博客 367

牛客周赛165C题(前后缀性质,递推,排序,枚举)

题目大意:给定长度为 `n` 的数组,选择 `k ∈ [1,n]`,将前 `k` 个元素整体翻转,后面的元素不变。要求操作后的整个数组非递减,统计满足条件的 `k` 的数量。题目链接:https://ac.nowcoder.com/acm/contest/141721/C。时间复杂度:O(nlogn)

2501_94316951的博客 170

【数据结构-3】算法美学之降复杂度

在while循环的循环体内,首先用临时变量保存最后一个位置的数据,再通过for循环把所有元素往后移动一位,最后把tmp中保存的值放到下标为0的位置上去。方法二的思路是:创建新数组,让原数组中后k个数据移动到新数组中前面的位置,让原数组中前numsSize-k个数据移动到新数组中后面的位置,这。这段代码的思路是:三次逆置,第一次逆置前numsSize-k个数据,第二次逆置后k个数据,最后整体逆置。这篇博文分享一道解法不一的算法题,求解过程的目的在于降低算法的时间复杂度,题源力扣。,属于空间换时间的操作。

weixin_44218929的博客 82

算法61,判定是否为字符重排

两字符串能互为重排 ⇔。

sheshibenniaodan的博客 217
上一篇: AtCoder Beginner Contest 347 A~F
下一篇: Codeforces April Fools Day Contest 2024 A~D.F~G
AC-Panda
博客等级 码龄5年 1736粉丝 191原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值