使用说明:
linux下需要编译 这里使用duipai.cpp程序来对拍的,没有用bash脚本 使用时,先编译4个文件(ac中放正确的标程/暴力程序 wa中自己的程序 rand是用来产生数据的) g++ duipai.cpp -o duipai g++ rand.cpp -o rand g++ ac.cpp -o ac g++ wa.cpp -o wa 然后运行duipai即可 ./duipai
duipai.cpp 对拍程序
#include<bits/stdc++.h>
using namespace std
;
int main(){
int Case
=1;
while(1){
printf("The result of No. %d Case is: ",Case
=1);
system("rand");
system("ac");
system("wa");
if (system("fc ac.out wa.out")){
printf("Wrong Answer\n");
return 0;
}
else printf("Accepted\n");
}
return 0;
}
rand.cpp 随机数生成程序,需自己造随机生成数据
#include<bits/stdc++.h>
using namespace std
;
#define random(a,b) ((a)+rand()%((b)-(a)+1))
stringstream ss
;
int main( int argc
, char *argv
[] ){
freopen("data.in","w",stdout);
int seed
=time(NULL);
if(argc
){
ss
.clear();
ss
<<argv
[1];
ss
>>seed
;
}
srand(seed
);
int n
=5;
printf("%d\n",n
);
for(int i
=0 ; i
<n
; ++i
){
printf("%d ",random(0,10));
}
printf("\n");
return 0;
}
ac.cpp 暴力求解的超时标程
#include<bits/stdc++.h>
using namespace std
;
int main(){
freopen("data.in","r",stdin);
freopen("ac.out","w",stdout);
int n
,x
;
cin
>> n
;
int ans(0);
while (n
--){
cin
>> x
;
if (x
> 6) ans
++;
}
cout
<< ans
<< endl
;
return 0;
}
wa.cpp 自己的错误程序
#include<bits/stdc++.h>
using namespace std
;
int main(){
freopen("data.in","r",stdin);
freopen("wa.out","w",stdout);
int n
,x
;
cin
>> n
;
int ans(0);
while(n
--){
cin
>> x
;
if (x
>= 6) ans
++;
}
cout
<< ans
<< endl
;
return 0;
}
随机数和标程一定要造好!!!
转载请注明原文地址:https://ipadbbs.8miu.com/read-23807.html