cf

模板

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("filename.in", "r", stdin);
    //freopen("filename.out", "w", stdout);
    
    return 0;
}

一些算法

对于任意两个正整数 n,m 的最小公倍数为 n×m / gcd(n,m),其中 gcd(n,m) 为 n 和 m 的最大公约数。

subarray是截取数组中连续的一段子数组。 subsequence是序列中不连续的一段子序列

数据范围

int32的范围是2e9
int64是2e18

题目给的时限是1s,时间复杂度在1e7到1e8之间

代码

// 自动初始化为全0
vector<int> a(n);

// 改变长度
v.resize(n);

// 输入序列
for(auto& x: a) cin >> x;
for (int i = 0; i < n; i++) a.push_back(i);

// 检查序列中是否存在 连续重复 的元素
if (std::unique(a.begin(), a.end()) != a.end()) cout << "YES\n";

// 返回最后一个字符
string.back()
a.back()

// 输出空格
cout << " \n"[i == n-1];

// 倒序排列
sort(s.rbegin(), s.rend());

// 反转
reverse(a.begin(), a.end());

// 添加到序列的末尾
a.push_back(x)

// 打印序列
for(auto x: a) cout << x << " \n"[x == a.back()];

// 找到数组 `a` 中的最大值 `mx`
int mx = *max_element(a.begin(), a.end());

解释器/编译器

Python 解释器

  • Python 2.7.18:已废弃 (2020年停止维护),遗留项目使用
  • Python 3.13.2:当前主流版本
  • PyPy 2.7.13:兼容 Python 2.7,JIT 编译
  • PyPy 3.6.9:兼容 Python 3.6,JIT 编译
  • PyPy 3.10 (7.3.15):兼容 Python 3.10,最新稳定版,JIT 编译

建议:新项目使用 Python 3.13.2

GCC/G++ 编译器

编译器 标准 说明
GCC C11 5.1.0 C11 较旧版本
G++17 7.3.0 C++17 较旧,稳定
G++20 13.2 C++20 较新,64位
G++23 14.2 C++23 最新实验版

建议:竞赛用 G++17 或 G++20

C++ 编译器选项 (Codeforces)

编译器 说明
C++ (g++) GCC 的 C++ 编译器
C++ (clang++) Clang 的 C++ 编译器

GCCClang 是两种不同的编译器,但语法兼容。选 C++ 的话用 g++clang++ 都可以。


cf
https://mingsm17518.github.io/2026/03/18/algorithm/others/cf/
作者
Ming
发布于
2026年3月18日
更新于
2026年3月26日
许可协议