//对拍 #include<bits/stdc++.h> using namespace std; int main(){ for(int i=1;;i++){ system("./data"); system("./std"); system("./test"); if(system("diff test.out std.out")){ printf("Wrong Answer! No:%d ",i); break; } else { printf("Accepted. No:%d ",i); } } return 0; }
//数据 #include<bits/stdc++.h> using namespace std; int main(){ freopen("data.in","w",stdout); srand(time(NULL)); int a=rand()%100+1; int b=rand()%100+1; printf("%d %d ",a,b); return 0; }
//标程 #include<bits/stdc++.h> using namespace std; int main(){ freopen("data.in","r",stdin); freopen("std.out","w",stdout); int a,b; scanf("%d%d",&a,&b); printf("%d ",a+b); return 0; }
//测试 #include<bits/stdc++.h> using namespace std; int main(){ freopen("data.in","r",stdin); freopen("test.out","w",stdout); int a,b; scanf("%d%d",&a,&b); if(a%5==0){ printf("%d ",a); return 0; } printf("%d ",a+b); return 0; }
当然测试代码有一个地方是错的。
然后重点在于生成数据:
来一个随机生成树的数据生成:
#include<bits/stdc++.h> using namespace std; int n,m,cnt,fa[100015]; int zhao(int xx){ if(fa[xx]==xx) return xx; else return zhao(fa[xx]); } int main(){ freopen("data.in","w",stdout); srand(time(0)); int n=rand()%298+2; printf("%d %d ",n,n-1); for(int i=1;i<=n;i++){ fa[i]=i; } while(cnt<n-1){ int x=rand()%n+1,y=rand()%n+1; int x1=zhao(x),y1=zhao(y); if(x1!=y1){ fa[x1]=y1,cnt++; printf("%d %d ",x,y); } } return 0; }
排版有点乱。
额嗯嗯嗯嗯
时隔5天后,我又来了
下面是带时间的对拍程序
#include <bits/stdc++.h> using namespace std; int main(){ srand(time(NULL)); for(int i=1;i;i++){ system("./data"); double st=clock(); system("./test"); double ed=clock(); system("./std"); if(system("diff std.out test.out")){ printf("Wrong No:%d ",i);break; } else { printf("Accept No:%d time:%.3lfms ",i,ed-st); } } }
感觉听简单的