zoukankan      html  css  js  c++  java
  • 对拍与数据生成(万能版)

    //对拍
    #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);
    		}
    	}
    	
    }
    

     感觉听简单的

  • 相关阅读:
    在R语言中轻松创建关联网络
    在R语言中显示美丽的数据摘要summary统计信息
    R语言中不同类型的聚类方法比较
    R语言中的划分聚类模型
    R语言解释生存分析中危险率和风险率的变化
    Stata估算观测数据的风险比
    Stata 中Mata的st_view函数
    R语言多臂试验
    R语言使用倾向评分提高RCT(随机对照试验)的效率
    R语言在RCT中调整基线时对错误指定的稳健性
  • 原文地址:https://www.cnblogs.com/DZN2004/p/13193011.html
Copyright © 2011-2022 走看看