当前位置: 首页 > ai >正文

XCPC 常用技巧

命令行编译

如果用 vscode,sublime 这样的文本编辑器写代码的话,一般写完代码都需要在命令行进行编译运行(不是所有场次的 vscode 都会安装 Code Runner,所以有时需要手动编译运行)。

C++ 编译命令

g++ A.cpp -o A -Wall -lm -std=c++20
./A
  • 其中的 A.cpp 可以换成要编译的源文件。
  • 第二个 A 是生成的可执行的名称,这个可执行文件的名称必须与第二行 ./ 后的内容相同,这样才能运行相应的程序。
  • -std=c++20 是指定用 C++20,可以根据比赛环境换成相应的 C++ 版本

Linux 环境下的对拍

对拍一般是用一个暴力程序判断自己写的程序是否有错,比赛的操作系统一般都是 Linux 系统。

data.cpp:用于造数据

#include <bits/stdc++.h>
using namespace std;int main() {ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);srand(time(0));cout << rand() % 1000000 << " " << rand() % 1000000 << endl;return 0;
}

bf.cpp:暴力程序

#include <bits/stdc++.h>
using namespace std;int main() {ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);int a, b;cin >> a >> b;cout << a + b << endl;return 0;
}

std.cpp :待检测的程序

#include <bits/stdc++.h>
using namespace std;int main() {ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);int a, b;cin >> a >> b;cout << a - b << endl;return 0;
}

pai.cpp:对拍脚本

#include <bits/stdc++.h>
using namespace std;int main() {ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);int t = 1;while (1) {cout << "test " << t++ << endl;system("./data > data.in");system("./std < data.in > std.out");system("./bf < data.in> bf.out");if (system("diff bf.out std.out")) break;}return 0;
}
http://www.xdnf.cn/news/10401.html

相关文章:

  • Beta分布Dirichlet分布
  • [Python] Python中的多重继承
  • 飞牛fnNAS装机之迷你小主机的利旧
  • SolidWorks软件的安装与卸载
  • 12 Java GUI
  • Word双栏英文论文排版攻略
  • 【解决】【亲测下载obsidian可行】打不开github.com 或者 加速访问 github
  • Pull Request Integration 拉取请求集成
  • Python实现HPSO-TVAC优化算法优化支持向量机SVC分类模型项目实战
  • QT/c++航空返修数据智能分析系统
  • 重读《人件》Peopleware -(15)Ⅱ 办公环境 Ⅷ 撑伞之步:构建理想办公环境(上)
  • 数据中台(大数据平台)之数据安全管理
  • InternVL2.5-多模态大模型评估专业图片
  • Python爬虫:AutoScraper 库详细使用大全(一个智能、自动、轻量级的网络爬虫)
  • 从模式到架构:Java 工厂模式的设计哲学与工程化实践
  • 【办公类-22-05】20250601Python模拟点击鼠标上传CSDN12篇
  • 开始使用 Elastic AI Assistant for Observability 和 Amazon Bedrock
  • 接口自动化常用断言方式
  • 小明的Java面试奇遇之商城系统的技术挑战与实战
  • 考研系列—操作系统:第五章、输入输出(I/O)管理
  • Cesium快速入门到精通系列教程三
  • c++学习值---模版
  • 【计算机网络】第3章:传输层—可靠数据传输的原理
  • [蓝桥杯]外卖店优先级
  • 【极客日常】分享go开发中wire和interface配合的一些经验
  • C++ 之 多态 【虚函数表、多态的原理、动态绑定与静态绑定】
  • Scratch节日 | 六一儿童节射击游戏
  • ​​技术深度解析:《鸿蒙5.0+:全场景能效的产业革命》​
  • idea中springboot2.7(由于步入另一个线程,已跳过 xxx 处的断点)
  • Azure Devops 系列之三- vscode部署function app