zoukankan      html  css  js  c++  java
  • 对拍

    对拍

    对拍程序

    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        for(int i=1;i<=100000;i++){
            system("mk");
            system("my < in.txt > my.out");//my 和 std可替换成自己的程序名
            system("std < in.txt > std.out");
            if(system("fc my.out std.out")){//windows下是fc,linux是diff
                puts("!!!!!!");
                while(1);
            }
        }
        return 0;
    }
    

    mk(造数据)

    大体框架

    #include <bits/stdc++.h>
    using namespace std;
    const int N=30000;
    const int inf=1e9;
    int main(){
        int seed;
        freopen("seed.txt", "r", stdin);
    	scanf("%d",&seed);
        srand(seed+time(0));
        for(int i=0;i<5;i++) rand();
        freopen("seed.txt", "w", stdout);
        printf("%d
    ",rand());
    
        freopen("in.txt","w",stdout);
        int n=rand()%N;
        printf("%d
    ",n);
        for(int i=1;i<=n;i++)
            printf("%d ",rand()%n);
        return 0;
    }
    
    

    无向图:

    #include <cstdio>
    #include <ctime>
    #include <algorithm>
    
    using namespace std;
    int vis[1000][1000];
    const int N=1e6+10;
    int main(){
    	
    	int seed;
    	freopen("seed.txt", "r", stdin);
    	scanf("%d",&seed);
    
    	srand(seed+time(0));
    	for(int i=0;i<5;i++) rand();
    
    	freopen("seed.txt","w",stdout);
    	printf("%d
    ", rand());
    
    	freopen("in.txt","w",stdout);
    	int t=rand()%10;
        while(t--){
            int n=rand()%N;
            int m=rand()%(5*N);
            printf("%d %d
    ",n,m);
            for(int i=1;i<=n;i++)
                printf("%d ",rand()%10000);
            for(int i=1;i<=m;i++){
    			int x=1,y=1;
    			while(x==y || vis[x][y]){
    				x = rand()%n+1;
    				y = rand()%n+1;
    			}
    			vis[x][y] = vis[y][x] = 1;// wuxiangtu
    			printf("%d %d
    ",x,y);
    
    		}
        }
    	return 0;
    }
    

    树:

    while(cnt<n-1){
        int x=rand()%n+1;
        int y=rand()%n+1;
        int xx=find(x);
        int yy=find(y);
        if(xx==yy)continue;
        f[xx]=yy;++cnt;
        cout<<x<<" "<<y<<endl;
    }
    

    简易方法:

    for(int i=1;i<n;i++)
    	printf("%d %d
    ",i,rand()%(i-1)+1);
    
  • 相关阅读:
    android模拟器速度问题
    input.nextLine() 问题出错!
    android中的“visible ”、“invisible”、“gone”的区别(转载)
    为什么匿名内部类参数必须为final类型(转载)
    转载------------------关于android的一些技巧
    关于数据库的数据类型
    关于几个新的快捷键
    目标

    巨大bug
  • 原文地址:https://www.cnblogs.com/ke-xin/p/14049878.html
Copyright © 2011-2022 走看看