对拍与数据生成(万能版)

//对拍
#include
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\n",i);
                  break;
            } else {
                  printf("Accepted. No:%d\n",i);
            }
      }
      return 0;
}
//数据
#include
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\n",a,b);
      return 0;
}

//
标程 #include 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\n",a+b); return 0; }

 

//测试
#include
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\n",a);
            return 0;
      }
      printf("%d\n",a+b);
      return 0;
}

当然测试代码有一个地方是错的。

 然后重点在于生成数据:

 

来一个随机生成树的数据生成:

#include
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,n-1);
    for(int i=1;i<=n;i++){
     fa[i]=i;
  }
    while(cnt 
 

 排版有点乱。

你可能感兴趣的:(对拍与数据生成(万能版))