调不过可以尝试这一组hack数据
查看原帖
调不过可以尝试这一组hack数据
452438
_Minecraft12345楼主2024/7/8 13:55

这组数据是我将1打成0然后调了5.5小时最后对拍后才过的,我的代码非常离谱的好看,精简的只有244行,所以不放了。

10 10
1 0 0 0 1 0 0 1 1 1 
0 5 9
0 5 8
4 9 9
4 6 6
4 6 6
2 5 9
2 3 6
1 5 8
4 4 9
4 4 9

顺便附上windows下可以用的对拍程序和数据生成器(正解自己从题解或其他什么地方找就可以了)

duipai.cpp

#include<cstdio>
#include<cstdlib>
#include<ctime>

int main()
{   long s,t;
    while(1){
        system("cls");
        do{
            system("data.exe > try.in"); //data是数据生成程序
            s=clock();
            system("a.exe < try.in > try1.out");  //a是要交的程序
            t=clock();
            system("b.exe < try.in > try2.out");  //b是正确的程序
            if(system("fc try1.out try2.out > nul"))
                break;
            //else printf("AC time: %ldms\n",t-s);//如果需要看可以取消注释
        }while(1);
        printf("WA time: %ldms\n",t-s);  //运行时间 
        system("fc try1.out try2.out");
        system("pause>nul");
    }
    return 0;
}

data.cpp

#include<bits/stdc++.h>
using namespace std;
int main(){
	srand(time(0));
	ios::sync_with_stdio(0);
	int n=10,m=10;
	cout<<n<<' '<<m<<'\n';
	for(int i=1;i<=n;i++){
		int ai=rand()%2;
		cout<<ai<<' ';
	}cout<<'\n';
	for(int i=1;i<=m;i++){
		int op=rand()%5;
		cout<<op<<' ';
		int l=rand()%n;
		int r=rand()%n;
		while(r<l)r=rand()%n;
		cout<<l<<' '<<r<<'\n';
	}
	return 0;
}

需要将所有程序先编译出exe才能运行

2024/7/8 13:55
加载中...