首页 > 其他分享 >数据生成大师

数据生成大师

时间:2022-10-11 16:36:03浏览次数:40  
标签:Write 10000 Numbercnt int 生成 char putchar 数据 大师

看到的,好多东西!

数据生成大师!

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e6 + 50;
int Case;
char c;
char namein[MAXN], nameout[10000], Oin[10000], Oout[10000];  // Oout
inline void Write(int x, char c) {
  int Putout[35], Numbercnt = 0;
  while (x)
    Putout[++Numbercnt] = x % 10, x /= 10;
  for (int i = Numbercnt; i >= 1; i--)
    putchar(Putout[i] + '0');
  if (Numbercnt == 0)
    putchar('0');
  putchar(c);
  return;
}
void work(int number) {  // 在这里造输入数据,可以根据传入的数据编号给部分分
  int n = 200000, m = 200000;
  Write(n, ' '), Write(m, '\n');
  for (int i = 1; i <= n; i++) {
    int x = (rand() << (rand() & 1) << (rand() & 1)) % i + 1;
    Write(x, ' ');
  }
  putchar('\n');
  for (int i = 1; i <= m; i++) {
    int l = rand() % 50 + 1, r = l + 190000;
    Write(l, ' '), Write(r, '\n');
  }
  return;
}

signed main() {
  srand(time(NULL));
  printf("\nPlease enter the title of the data to be created (without any ""suffix):");
  scanf("%s", namein);
  printf("\nPlease input the quantity of data to be created:");
  scanf("%lld", &Case);
  printf("\nOk, please wait a moment!");
  system("g++ -Wl,-stack=1073741824 -std=c++11 std.cpp -O2 -o std");
  //标程需要命名为
  //std,并且造数据的时候std要开文件读写,并且命名要求跟你要造的题目同名。
  int len = strlen(namein);
  for (int i = 0; i < len; i++)
    Oout[i] = Oin[i] = nameout[i] = namein[i];
  for (int i = 1; i <= Case; i++) {
    int x = i, L[20], t = 0, now = len;
    while (x) {
      L[++t] = x % 10;
      x /= 10;
    }
    while (t) {
      namein[now] = (char)(L[t] + '0'), now++, t--;
    }
    namein[now] = '.';
    namein[now + 1] = 'i';
    namein[now + 2] = 'n';
    freopen(namein, "w", stdout);
    work(i);  // 在这里造数据
    fclose(stdout);
  }
  Oin[len] = '.', Oin[len + 1] = 'i', Oin[len + 2] = 'n';
  Oout[len] = '.', Oout[len + 1] = 'o', Oout[len + 2] = 'u',
  Oout[len + 3] = 't';
  for (int i = 1; i <= Case; i++) {
    int x = i, L[20], t = 0, now = len;
    while (x) {
      L[++t] = x % 10;
      x /= 10;
    }
    while (t) {
      nameout[now] = (char)(L[t] + '0'), now++, t--;
    }
    nameout[now] = '.';
    nameout[now + 1] = 'i';
    nameout[now + 2] = 'n';
    freopen(nameout, "r", stdin);
    freopen(Oin, "w", stdout);
    while ((c = getchar()) != EOF)
      putchar(c);
    fclose(stdout), fclose(stdin);
    system("std");
    nameout[now] = '.';
    nameout[now + 1] = 'a';
    nameout[now + 2] = 'n';
    nameout[now + 3] = 's';
    freopen(Oout, "r", stdin);
    freopen(nameout, "w", stdout);
    while ((c = getchar()) != EOF)
      putchar(c);
    fclose(stdout), fclose(stdin);
    nameout[now] = '\0';
    nameout[now + 1] = '\0';
    nameout[now + 2] = '\0';
    nameout[now + 3] = '\0';
  }
  return 0;
}

标签:Write,10000,Numbercnt,int,生成,char,putchar,数据,大师
From: https://www.cnblogs.com/ptno/p/16779650.html

相关文章