zoukankan      html  css  js  c++  java
  • 对拍程序的写法

    每次对拍都是查http://blog.csdn.net/code12hour/article/details/51252457这里。一来二去就会写了。

    由于对Windows系统并不了解(Linux就更不了解了),所以口胡可能有纰漏欢迎指正。


    首先新建一个文件夹“对拍”。  ——这个文件夹叫什么放在哪都无关紧要

    在这个文件夹下放入制造数据的程序data.exe,你的程序test.exe,标程std.exe。  ——其它文件在这个文件夹中也无所谓,重名也没事。比如可以放一个std.cpp

    一般编译器都能通过data.cpp生成data.exe。

    data.cpp的写法

    #include<iostream>//输入输出 
    #include<ctime>//time() 
    using namespace std;
    int main(){
        srand(time(NULL));
        //比如生成一个长度随机的10000以内序列,输出长度n与ai~an 
        int n=rand()<<15|rand();//这样造出的rand数更随机
        cout<<n<<endl;
        while(n--){
            cout<<(rand()<<15|rand())%10000<<' ';
            //cout<<(rand()<<15|rand())%10000+1<<' ';
            //保证数据在[0,9999]。如果要[1,10000],就用第二行的 
        }
        return 0;
    }

    最重要的就是“对拍.bat”了

    :again
    data>in.txt
    std<in.txt>stdout.txt
    test<in.txt>testout.txt
    fc stdout.txt testout.txt
    if not errorlevel 1 goto again
    pause

    data,std,test都是取决于exe的文件名的。系统会先用你的data.exe生成一个in.txt,再用in.txt作为输入传给test.exe和std.exe,运行后会得到stdout.txt,testout.txt。

    比较无差异就会一直进行下去,直到出现差异就pause,文件夹中会有这个错误点的in.txt,testout.txt,stdout.txt。


    如果一直无差异可能你就已经A了这道题!

    但数据范围要把控好。

    综上。完。

  • 相关阅读:
    bzoj4804
    bzoj2962
    bzoj4827
    bzoj2553
    bzoj3611
    BZOJ 1636: [Usaco2007 Jan]Balanced Lineup
    BZOJ 1635: [Usaco2007 Jan]Tallest Cow 最高的牛
    BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers
    BZOJ 1631: [Usaco2007 Feb]Cow Party
    BZOJ 2582: [Usaco2012Jan]Bovine Alliance
  • 原文地址:https://www.cnblogs.com/orzzz/p/7461802.html
Copyright © 2011-2022 走看看