对拍

  1. 使用随机数提供数据
    如下代码 gen.cpp,产生 \(n\)\(-1\)\(1\) 的随机数,编译生成 gen.exe
#include <iostream>
#include <random>//rand()最大32767
using namespace std;
mt19937 d1(random_device{}());
const int N = 3e4 + 7;
int a[N];
int main() {
	int n = d1() % 20;
    printf("%d\n", n);
    for (int i = 1; i <= n; ++i) {
		int x = d1()%2;
		if (!x) x = -1;
        printf("%d ", x);
    }
    return 0;
}
  1. 分别写出测试程序 TT.exe 以及标程 lec.exe,使用批处理程序 对拍.bat 测试,代码如下:
@echo off
:loop
	gen > 1.in
	TT < 1.in > 1.out
	lec < 1.in > 1.ans
	fc 1.out 1.ans
	if not errorlevel 1 goto loop
pause
goto loop

所有程序文件均放在同一个文件夹下,然后双击 对拍.bat 开始测试。

  1. Linux
#!/bin/bash
while true; do
    ./rand > input
    ./baoli < input > baoli.out
    ./hao  < input > hao.out
    diff -b baoli.out hao.out
    if [ $? -ne 0 ]; then break; fi
done
posted @ 2024-10-04 15:13  飞花阁  阅读(23)  评论(0)    收藏  举报
//雪花飘落效果