使用說明:
這裡使用duipai.cpp程式來對拍的,沒有用bash腳本
使用時,先編譯4個檔案(std中放正确的标程/暴力程式 my中自己的程式 rand是用來産生資料的)
g++ duipai.cpp -o duipai
g++ 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; }