算法竞赛数据生成及使用Sublime对拍
创始人
2024-11-15 17:37:06
0

写在前面:最近几天看蒋老师直接使用了Sublime中的FastOlympicCode插件进行了对拍,出于兴趣来学习一下,关于插件的配置已经有很多大佬讲过啦,这里不再赘述。数据生成的代码我会放到最后,包括生成数组、区间、树、图。

如何使用Sublime进行对拍

首先,如果我们需要对d.cpp这个文件进行对拍,就需要创建d__Good.cppd__Generator.cpp两个文件,顾名思义,前者是正确代码,而后者是数据生成的代码,注意两个文件中都带有两个下划线。

然后,我们在需要对拍的文件中按下ctrl+shift+p找到FastOlympicCoding:Make Stress
在这里插入图片描述
然后回车即可,下图表示程序正在编译
在这里插入图片描述
编译完成后,对拍进行过程如下图所示,找到错误数据后对拍会自动暂停。
在这里插入图片描述

如何生成数据

这里给出一份生成数据的代码,可以生成数组、区间、树、图,供大家参考。

如有错误欢迎您及时向我指出。

#include  using i64 = long long;  std::mt19937 rnd(std::chrono::steady_clock().now().time_since_epoch().count());  int rng(int l, int r) { // [l, r] 	return rnd() % (r - l + 1) + l; }  void array(int n) { // Generates an array with n elements 	int m = 1E9; 	std::vector a(n); 	for (int i = 0; i < n; i++) { 		a[i] = rng(0, m); 		std::cout << a[i] << " \n"[i == n - 1]; 	} }  void cand(int m, int n) { // Generate m cands from 1 to n 	for (int i = 0; i < m; i++) { 		int l = rng(1, n); 		int r = rng(1, n);  		if (l > r) { 			std::swap(l, r); 		}  		std::cout << l << " " << r << "\n"; 	} }  void tree(int n) { // Generate a tree with n vertices 	int m = 1E9; 	for (int i = 1; i < n; i++) { 		int p = rng(0, i - 1); 		int v = rng(1, m); 		std::cout << p + 1 << " " << i + 1 << " " << v << "\n"; 	} }  void graph(int n, int m) { // Generate an undirected graph with n vertices and m edges. There are no double edges or self-rings in the graph, and must be connected. 	std::vector> e; 	std::map, bool> f;  	std::cout << n << " " << m << "\n";  	for (int i = 1; i < n; i++) { 		int p = rng(0, i - 1); 		e.push_back(std::make_pair(p, i)); 		f[std::make_pair(p, i)] = f[std::make_pair(i, p)] = true; 	}  	// debug(f); 	for (int i = n; i <= m; i++) { 		int x, y; 		do { 			x = rng(0, n - 1); 			y = rng(0, n - 1); 		} while (x == y || f.count(std::make_pair(x, y)));  		e.push_back(std::make_pair(x, y)); 		f[std::make_pair(x, y)] = f[std::make_pair(y, x)] = true; 	}  	std::shuffle(e.begin(), e.end(), rnd);  	for (auto [x, y] : e) { 		std::cout << x + 1 << " " << y + 1 << "\n"; 	} }  int main() { 	int t = 5; 	std::cout << t << "\n";  	while (t--) { 		graph(3, 3); 	}  	return 0; } 

相关内容

热门资讯

透视免费“hhpoker怎么开... 透视免费“hhpoker怎么开透视”确实真的有挂(辅助挂)详细辅助专业教程辅助器中分为三种模型:软件...
重要通知“邳州友友辅助软件”w... 重要通知“邳州友友辅助软件”wepoker黑侠辅助器正版下载(固有有挂);亲真的是有正版授权,小编(...
透视app!hh poker辅... 透视app!hh poker辅助器先试用,兴动互娱辅助脚本,解密教程(有挂介绍)小薇(透视辅助)致您...
教程攻略“凑一桌游戏软件下载辅... 教程攻略“凑一桌游戏软件下载辅助”wepoker透视脚本免费(原生真的有挂);最新版2024是一款经...
透视模拟器“aapoker透视... 透视模拟器“aapoker透视软件”一直真的有挂(辅助挂)详细辅助透明挂教程1、系统规律教程、辅助透...
透视辅助!wpk辅助软件,土豪... 透视辅助!wpk辅助软件,土豪联盟辅助,总结教程(有挂介绍)1、下载好土豪联盟辅助辅助软件之后点击打...
查到实测“中指小程序破解头像”... 查到实测“中指小程序破解头像”we-poker辅助器(总是是有挂);原来确实真的有挂(需添加指定薇1...
透视辅助!wepoker分析,... 透视辅助!wepoker分析,牵手游戏辅助软件,透明挂教程(有挂细节);1、完成牵手游戏辅助软件的残...
透视app“wpk辅助插件叫什... 透视app“wpk辅助插件叫什么”总是真的有挂(辅助挂)详细辅助安装教程;辅助器中分为三种模型:软件...
推荐一款“广东雀神智能插件安装... 推荐一款“广东雀神智能插件安装软件”wejoker辅助软件价格(真是有挂)1、不需要AI权限,帮助你...