I have a problem. How to make data for it?
Part 1: preparation
First, you should have a standard procedure, that is \ (\ texttt{std} \), so that you can generate a correct output data for your input data.
Then, you should have a program to generate data, that is \ (\ texttt{gen} \), see Part 2 for details.
Part 2: write a gen
Most of the principles of \ (\ texttt{gen} \) are generated randomly, and \ (\ texttt{gen} \) can be typed according to the template, such as randomly generating a sequence:
//The preparation before operation is run in the console (i.e. the pop-up black box): srand(time(NULL)); //To generate a random number, this line must be added int n, maxa; cin >> n >> maxa; //Read in the maximum values of n and a freopen("hhhhc.in","w",stdout); //Output your input data to HHC In file cout << n << endl; //The first line of the input data of the topic may be an n. when creating the input data, you should find the input format for output for (int i = 1; i <= n; i ++) cout << rand()%maxa+1 << ' '; //Randomly generate n integers and output
Run this program, and then pop up a window. After entering the maximum value maxa of sequence length \ (n \) and sequence \ (a \), it will be displayed in exe file in the same directory to generate a file named hhhhc In, which contains a sequence of numbers with a length of \ (n \) and no more than \ (maxa \).
Generate a \ (\ texttt{gen} \) of \ (1\sim n \) permutation (random data) as follows:
#include <bits/stdc++.h> using namespace std; int p[100005]; //Generated permutation int main() { srand(time(NULL)); int n; cin >> n; //Enter the arrangement length // freopen("kkksc03.in","w",stdout); for (int i = 1; i <= n; i ++) { int x = -1; //subscript while (x==-1 || p[x]) x = rand() % n + 1; //If this number has been generated, it should be regenerated in order to avoid duplicate numbers p[x] = i; //The current number is stored in the spread } for (int i = 1; i <= n; i ++) cout << p[i] << ' '; return 0; }
Method of generating a random interval:
//Method 1: randomly generate l in [1,n], and then randomly generate r in [l + 1,n] int l = rand() % n + 1; int r = rand() % (n-l+1) + l; //Method 2 (recommended): randomly generate two numbers l,r in [1,n]. If R < L, exchange l,r int l = rand() % n + 1, r = rand() % n + 1; if (r < l) swap(l,r);
There are many ways to generate many different data, which depends on your own thinking(
There are also some \ (\ texttt{gen} \) that make hack data, such as
//P7996 No answer! gen of the situation cout << 114514; for (int i = 1; i <= 114514; i ++) cout << 1 << ' ';
Show me the \ (\ texttt{gen} \) of P7996:
#include<bits/stdc++.h> using namespace std; int main() { long long n,k,a,b; cout<<"Please enter n,k,ai Upper and lower values of:"; cin>>n>>k>>a>>b; freopen("1.in", "w", stdout); cout<<n<<" "<<k<<'\n'; for(int i=0; i<n; i++) { cout<<rand()%(b-a+1)+a<<' '; // if(i<50000) cout<<2500; // else cout<<3500; // cout<<' '; // cout <<"7000000 "; // cout << i+a << ' '; } return 0; }
Part 3: manufacturing input data
Your \ (\ texttt{std,gen} \) must be in the same directory.
Just use your \ (\ texttt{gen} \) to create input data.
For example, the \ (\ texttt{gen} \) of P7996 above only needs to run and generate 1 In, put 1 In manually changed to 2 in,3.in \ (... \) and then run them separately to generate these input data.
If you need to generate hack data halfway, just change your \ (\ texttt{gen} \).
Part 4: manufacturing output data
Create an output. Net file in the directory where the data is stored Cpp file, enter:
#include<cstdio> int main() { freopen("run.bat","w",stdout); for(int i=1; i<=n; ++i) //n is the number of your data sets printf("std < %d.in > %d.out\n",i,i); return 0; }
Then, do not add freopen to your \ (\ texttt{std} \) and run the output Exe, and then you will find a run. Exe in your directory Bat file, run this file and wait for the pop-up window to close, and you will find that your output data has been created.
Part 5: attention!
- The name of your \ (\ texttt{std,gen} \) must be std.cpp, gen.cpp and std.exe, gen.exe, otherwise an error will occur when generating output data.
- Your data name should preferably be 1 in 2. In \ (... \) x.In and 1 out 2. Out \ (... \) x.out, otherwise you need to change your output cpp.
- When uploading data, you need to compress the file into a folder, preferably named data Zip. Don't put anything in it except input data and output data. (if you want to make a special evaluation, you can insert files such as checker.cpp)
Part 6: pay more attention!
Click a like before you go \ (\ sim \)
If there is something inappropriate, you can put forward oh \ (\ sim \)