对拍和随机数据生成

c++ 对拍

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
using namespace std;
typedef long long ll;
int main()
{
    for(int t = 1;t <= 100000;t ++){
        system("E:\\noip\\random.exe");
        double st = clock();
        system("E:\\noip\\1.exe");
        double en = clock();
        system("E:\\noip\\2.exe");
        if(system("fc E:\\noip\\data.out E:\\noip\\data.ans")){
            cout<<"WA"<<endl;return 0;
        }
        else {
            cout<<"AC"<<endl;
            printf("%.0lfms\n",en - st);
        }
    }
    return 0;
}

随机生成图

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<map>
using namespace std;
typedef long long ll;
pair <int,int> e[10011];
map < pair<int,int> ,bool> h;
ll random(ll n){
    return (ll)rand()*rand()%n;
}
int main()
{
    freopen("data.in","w",stdout);
    srand(time(0));
    int n = 500,m = 10001;
    cout<<n<<" "<<m<<endl;
    for(int i = 1;i < n;i ++){
        int fa = random(i) + 1;
        e[i] = make_pair(fa,i + 1);
        h[e[i]] = h[make_pair(i,fa)] = 1;
    }
    for(int i = n;i <= m;i ++){
        int x,y;
        do{
            x = random(n) + 1,y = random(n) + 1;
        }while(x == y || h[make_pair(x,y)]);
        e[i] = make_pair(x,y);
        h[e[i]] = h[make_pair(y,x)] = 1;
    }
    for(int i = 1;i <= m;i ++){
        printf("%d %d\n",e[i].first,e[i].second);
    }
    return 0;
}

随机生成树

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<map>
using namespace std;
typedef long long ll;
pair <int,int> e[10011];
map < pair<int,int> ,bool> h;
ll random(ll n){
    return (ll)rand()*rand()%n;
}
int main()
{
    freopen("data.in","w",stdout);
    srand(time(0));
    int n = 500;
    cout<<n<<endl;
    for(int i = 1;i < n;i ++){
        int fa = random(i) + 1;
        cout<<fa<<" "<<i + 1<<endl;
    }
    return 0;
}

原文地址:https://www.cnblogs.com/wtz2333/p/12233135.html

时间: 2024-08-29 14:43:18

对拍和随机数据生成的相关文章

随机数据生成与对拍

# 随机数据生成与对拍 引言 在漫长的\(OI\)生涯中,你肯定遇到过这些情况 在OI赛制下,你写了一份你自认为是正解的代码,但是你不确定自己是否考虑到了所有的细节,你不敢轻易提交 对于有些无法获得数据的题目,你不知道自己错在了哪里 对于能够获得数据的题目,你拿到的数据都是上万级别的数据,难以\(Debug\). 这时候,我们就可以试试随机数据生成与对拍` 什么是随机数据生成? 顾名思义,就是针对我们的需求生成随机的数据.比如生成随机的整数序列,生成随机的树,生成随机的图. 什么是对拍? 对拍说

机器学习算法的随机数据生成

在学习机器学习算法的过程中,我们经常需要数据来验证算法,调试参数.但是找到一组十分合适某种特定算法类型的数据样本却不那么容易.还好numpy, scikit-learn都提供了随机数据生成的功能,我们可以自己生成适合某一种模型的数据,用随机数据来做清洗,归一化,转换,然后选择模型与算法做拟合和预测.下面对scikit-learn和numpy生成数据样本的方法做一个总结. 1. numpy随机数据生成API numpy比较适合用来生产一些简单的抽样数据.API都在random类中,常见的API有:

d3 使用随机数据生成条形图

var dataset = d3.range(25).map(function(){ return d3.round(d3.random.normal(15,8)(),1); }) // 返回 [27.2, 12.9, 12.2, 6.8, 9.4, 7.1, 17.5, 30, 16.6, 24.3, 19, 16.6, 5.8, 6.1, 5, 32.3, 6.4, 17.5, 5.1, 19, 15.5, 22.4, 30.4, 6.2, 15.8] d3.range(25)  生成25个

随机数据生成工具Mockaroo

原文地址:https://www.cnblogs.com/zwh1993/p/Mockaroo.html

.NET使用Bogus生成大量随机数据

.NET如何生成大量随机数据 在演示Demo.数据库脱敏.性能测试中,有时需要生成大量随机数据.Bogus就是.NET中优秀的高性能.合理.支持多语言的随机数据生成库. Bogus的Github链接:https://github.com/bchavez/Bogus,图标如下: 安装Bogus 目前Bogus最新版是28.0.2,本文演示基本该版本,不保证官方以后会不会修改本文的使用方式. 使用Powershell: PM> Install-Package Bogus -Version 28.0.

随机数据的生成

import numpy as np # (1)random(d0,d1,....dn)用来生成d0*d1*....*dn维的数组.数组的值在[0,1)之间 np.random.rand(3,2,2)#生成一个3*2*2的数组 array([[[0.10141273, 0.97087629], [0.57045156, 0.62780166]], [[0.15425975, 0.21828791], [0.03630166, 0.60174227]], [[0.20345412, 0.51719

irms模拟数据生成及数据分析

一.数据准备 1.每天生成随机一个文本,每小时向文本中追加2次数据,每次10万条 随机数据生成: 2,32  * * * *  bash /mnt/jediael/irms/signalGenerator/signalGenerator.sh >> /home/jediael/sg.log 2>&1 类:SignalGenerator 2.每天将前一天生成的数据文本导入HDFS 32 0 * * * bash /mnt/jediael/irms/signalGenerator/c

Python一个可以生成随机数据的库

发现一个十分有用的库 faker,作用竟是可以生成各种各样的随机数据 新版本要使用 pip install fake-factory 而不能直接 pip install fake git:https://github.com/joke2k/faker文档:http://fake-factory.readthedocs.io/en/master/index.html 文档十分清楚, 用法就是这样的了, #-*- coding:utf-8 -*- from faker import Factory

利用Java随机,生成随机学生数据

为模拟向数据库中大量插入学生数据(注:此处应该用PreparedStatement.batchUpdate等批处理提高效率)的情形,通过Java随机来生成学生数据. 一.要生成的学生数据 students表设计如下: 其中前三项是数据库自动生成的,后面的10项需要程序生成. >>基于实际要求,插入的Student数据中,major和jnshuId不能同时相同.但由于随机数的不确定性,在程序中限制两个Student的major和jnshuId不同时相同复杂而低效.因此,选择在数据库中将major