使用说明:
这里使用duipai.cpp程序来对拍的,没有用bash脚本
使用时,先编译4个文件(std中放正确的标程/暴力程序 my中自己的程序 rand是用来产生数据的)
g++ duipai.cpp -o duipaig++ my.cpp -o my
g++ rand.cpp -o rand
g++ std.cpp -o std
然后运行duipai即可
./duipai
duipai.cpp
//重点!数据比较器 #include<bits/stdc++.h> using namespace std; int main(){ int i; for (i=1;;i++){ printf("The result of No. %d Case is: ",i); system("./rand"); system("./std"); system("./my"); if (system("diff std.out my.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); //以上为随机数初始化,请勿修改 //random(a,b)生成[a,b]的随机整数 //以下写你自己的数据生成代码 int n=5; printf("%d\n",n); for(int i=0 ; i<n ; ++i) { printf("%d ",random(0,10)); } printf("\n"); return 0; }
std.cpp
# include<iostream> # include<cstdio> # include<cstring> # include<algorithm> using namespace std; typedef long long ll; int main() { freopen("data.in","r",stdin); freopen("std.out","w",stdout); int n,x; cin>>n; int ans(0); while(n--) { cin>>x; if(x>6)ans++; } cout<<ans<<endl; return 0; }
my.cpp
# include<iostream> # include<cstdio> # include<cstring> # include<algorithm> using namespace std; typedef long long ll; int main() { freopen("data.in","r",stdin); freopen("my.out","w",stdout); int n,x; cin>>n; int ans(0); while(n--) { cin>>x; if(x>=6)ans++; } cout<<ans<<endl; return 0; }