对拍程序

常用算法代码模板 Java版 (2) :数据结构 常用算法模板 Java版——数据结构:链表、栈、队列、单调队列、模式匹配、Trie树、并查集、堆、哈希 阅读详情

在oj上提交程序,总是出现wa的时候会很苦恼,特别是你不知道那里错了的时候。

别怕,有了对拍程序,你再也不用担心找不出原因了!

对拍程序,是一个很好用的工具,上升一下,其实就是自动化测试工具

现在有A、B和C三个程序,其中A是完全正确的程序,B是你自己写的有一些bug(假如有的话),C是输入样例生成程序。


我们想让C自动随机生成输入样例data.in,然后A,B同时以data.in作为输入,产生各自的输出文件A.out,和B.out,最后对比两个输出。

如果输出文件相同(多次测试后),那么就可以假定A和B是等价的(A正确,B就正确);否则就是B程序在某个样例上与A对不上。这样就能帮我们更快定位bug。


现在我们让程序自动完成上面两行的工作,那么这个程序就是对拍程序,不妨称它为D程序:

D程序长这样:


#include <stdio.h>
#include <windows.h>
int main(){
    int t=100;
    while(t--){
        system("C.exe>data.in");
        system("A.exe<data.in>A.out");
        system("B.exe<data.in>B.out");
        if(system("fc A.out B.out")) break;
    }
    system("pause");
    return 0;
}

其中“<”为重定向输入,“>”为重定向输出

运行时要把A.exe B.exe 和C.exe放在D的工程目录下




如何编写对拍程序? 如何编写一个对拍程序来帮助查找程序的Bug。 阅读详情

相关推荐

对拍程序写法

搞信息学竞赛的我们常常会因为WA而苦恼——明明自己的测试数据都是对的怎么一提交就错了呢?这里介绍一种方法——对拍,它能使我们不耗费多余的时间苦苦手打测试数据。实现方法对拍,顾名思义,就是将两个程序给相同的输入,看看输出是否一样。既然如此,我们就需要几个步骤来实现它:生成测试数据;两个程序分别跑一遍,生成两个输出;比较两个输出。有人可能看到这里觉得可以用文件操作来完成。没错,是可以完成,但容易出错。...

weixin_41081104的博客 914

C++实现一个简单java对拍程序

使用c++实现java程序的对拍。

qq_42729417的博客 678

对拍(2020.11.12)B.pdf

对拍(2020.11.12)B

对拍器的使用

对拍器的基本概念是将两个不同实现的程序对同一组数据进行测试,并比较它们的输出。如果两者输出相同,则说明两者在这组输入下的行为是一致的。如果输出不同,就意味着其中至少有一个实现可能存在问题。通常,对拍器需要满足以下几个部分:随机数据生成器:用于生成大量随机测试数据,这些数据用于测试不同程序实现的表现。这些数据要尽可能多样化,以便覆盖各种可能的边界情况。暴力算法(参考算法):通常会先实现一个暴力但绝对正确的算法。这种算法的特点是,虽然可能在时间复杂度上不够高效,但它通常是比较容易实现且容易确保正确性的。

2302_78571314的博客 1676

拜耳阵列(Bayer Pattern)以及常见彩色滤波矩阵(CFA)

本文介绍了拜耳阵列的工作原理(Bayer Pattern)以及常用的彩色滤波矩阵(CFA)

风一样的男子(quinta)的博客 7120

JSSIP实战:5分钟搞定WebRTC电话功能(附完整代码示例)

本文通过JSSIP库实战演示如何在Web应用中快速集成WebRTC电话功能。文章提供了从环境准备、SIP服务器连接到完整代码示例的详细步骤,涵盖用户注册、拨号接听、媒体流处理等核心环节,并针对常见问题给出排查方案,帮助开发者高效实现网页端实时语音通信。

u8v9w0x1y的博客 517

对拍程序(易懂版)

对拍程序,window下使用

todaycode 968

SAP入门技术分享四:模块化程序

SAP入门技术分享三:模块化程序

ITxiaoangzai的博客 1152

对拍 详解

对拍详解 对拍是算法竞赛中除了瞪眼法以外 最有效的 debugdebugdebug 利器 它可以通过随机数据大体验证算法的正确性 比测大水样例有效多了 这里我拿洛谷P3628 [APIO2010]特别行动队(一道斜优板子)作为例题 要想对拍,首先你需要准备: 一个写好的暴力(一定要保证正确) 一个写好待测的正解 一个datamaker 一个checker 暴力: 写出暴力是对拍的必要条件 对于例题我们需要先写一个暴力 dpdpdp 代码: #include<bits/stdc++.h> #

Melancholy的博客 7642

基于51单片机扫地机器人(全套Proteus仿真+原理图+程序+说明书)

(内含源程序代码,原理图,仿真,讲解视频,元件清单等,【精品】值得推荐!!!扫地机器人是以单片机为主控制器。通过单片机控制小车行驶、除尘、蜂鸣。扫地机器人使用双电机驱动,以提高整车运动的平稳性;在智能车进驶过程中,采用双超声波模块实现避障。

2301_76434107的博客 1894

YOLOv8【第四章:注意力机制篇·第20节】一文讲透,注意力机制设计原则与选择指南 - 从原理到实践的系统化方法论!

🏆 本文收录于 《YOLOv8实战:从入门到深度优化》,该专栏持续复现网络上各种热门内容(全网YOLO改进最全最新的专栏,质量分97分+,全网顶流),改进内容支持(分类、检测、分割、追踪、关键点、OBB检测)。且专栏会随订阅人数上升而涨价(毕竟不断更新),当前性价比极高,有一定的参考&学习价值,部分内容会基于现有的国内外顶尖人工智能AIGC等AI大模型技术总结改进而来,嘎嘎硬核。    ✨ 特惠福利:目前活动一折秒杀价!一次订阅,永久免费,所有后续更新内容均免费阅读!

**My Coding Family** 896

对拍程序的写法

对拍是什么呢? 对拍就是你给两个程序,和一个随机数据生成器,然后系统去用这个随机数据生成器的输出作为你这两个程序的输入,然后比较你这两个程序的输出,可以找到一组使这两个程序输出不一样的数据(如果存在的话) 怎么对拍呢? 首先,新建一个文件夹, 然后,在里面放入biaoda.exe,和test.exe。 biaoda.exe是你暴力写的一个做法或者你从网上找的一份AC代码生成的程序

一蓑烟雨任平生 2万+

RK3588平台开发系列讲解(USB篇)UAC初识

📢本篇将介绍RK3588平台`UAC`的配置使用。

内核笔记 3876

程序对拍(普通程序对拍&特判程序对拍)

程序对拍(普通程序对拍&特判程序对拍) 目前SPJ的对怕程序不是很完善,多少会有算法不优等问题。如有问题敬请在评论区留言。【若转载请注明出处】 对拍程序初级版本,仅使用于非特判程序 需要实现如下图情况 @echo off :start rand.exe %random% > in.txt oj.exe < in.txt > oj.txt AC.exe < in.txt > AC.txt fc oj.txt AC.txt if not errorlevel 1 goto

Round_Moon 的博客 691

Unity接入抖音小程序侧边栏

Unity接入抖音小程序侧边栏功能实践总结 本文分享了Unity游戏接入抖音小程序侧边栏复访功能的实现过程。针对官方文档不清晰的问题,作者详细介绍了关键实现步骤:通过TT.CheckScene检测侧边栏可用性,利用OnShow事件监听判断用户是否从侧边栏进入,并提供了完整的UI交互代码示例。重点功能包括:检测宿主版本支持、区分侧边栏入口与非侧边栏入口的界面展示、实现跳转侧边栏场景等。文中附有官方文档链接和效果截图,为开发者提供了实用的接入参考方案。

类人_猿的博客 613

《C++等级认证CCF-GESP真题解析》专栏总目录

❤️ 专栏名称:《C++等级认证CCF-GESP真题解析》🌸 专栏介绍:中国计算机学会GESP《CCF编程能力等级认证》C++编程(1~8级)历届真题解析。🚀 订阅专栏:订阅后可阅读专栏内所有真题解析,真题持续更新中,欢迎订阅!

人生就是一个不断学习的过程 6287

程序对拍

程序对拍 一. 对拍 程序对拍就是使用暴力解的结果和其他解的结果进行对比。 这里需要三种程序:1. 随机生成数据的程序;2. 其他解程序; 3. 暴力解程序 @echo off :loop create.exe > in.txt main.exe < in.txt > myout.txt test.exe < in.txt > stdout.txt fc myout.txt stdout.txt if not errorlevel 1 got

有人找你的博客 287

深度学习工具包 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")

【实用】关于Ubuntu下的对拍程序

学了这么久的OI还不会对拍,下定决心准备学对拍,上网一搜,全是在Windows下对拍的.bat文件,然而Ubuntu表示水土不服,竟然有度娘搜不到的东西,最后还是找同机房cgz神犇要的对拍程序,衷心感谢 关于对拍 对拍可以找出自己找不出来的一些问题,有时候应该是大多时候样例太水了,比如输入1,输出2,对拍自己出数据自己测,还可以控制数据范围, \(^o^)/ 如何对拍 对拍有四个程序,分...

测试运算符 1470

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

对拍程序讲解及源码举例

对拍程序 一、介绍   在做题或者正式比赛过程中总会把水题做水做乱,但因为样例有坑所以直接过了样例,然后拿去评测结果发现全WA。那如何在这种情况下检查自己程序或算法的正确性呢?对拍是一个简便省事的方案。   所谓“对拍”,顾名思义,就是让两者相互比对。所谓“两者”,一是你要测试的程序,二是一个答案在该程序在一定范围(时间/空间)内结果必定正确的程序(一般是用暴力求解的程序)。  ...

XIAO01067922的博客 312

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

ACM 对拍程序

使用方法 新建四个cpp文件 分别是 zi.cpp baoli.cpp data.cpp duipai.cpp 分别写下 自己的代码,暴力保证100%正确的代码,生成本题的数据,对拍程序 先编译前三个cpp文件生成对应的exe文件后,运行 duipai.cpp 这个代码即可进行对拍 参考博客: 大佬1 大佬2 zj.cpp(zj 自己的code不保证 100%正确) #include<iostream> using namespace std; int main() { int

qq_43750980的博客 286

ACM对拍程序

以2019杭电多校的一道题为例。 题目传送门 将正确程序还有WA的程序放在同一目录下(这两个程序按照一般写法即可),然后再写个样例随机生成代码。然后代码都要编译一下,生成对应的exe文件,因为对拍程序调用的是exe文件,所以源代码改了,还要重新编译一下,更新exe文件。然后新建txt,写入一下代码。然后将文件后缀改为.bat,一切就绪后就可以双击.bat文件,windows会调用cmd窗口,显示运...

我们花时间收集,却忘了最重要的其实是花时间去消化 272
上一篇: 遗传算法解一道笔试题
下一篇: ryu安装总结
WayToAccept
博客等级 码龄14年 21粉丝 56原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值