鉴于最近要组ACM比赛,又加上万恶的CF不仅用不了RMJ,还有半辈子过不了的人机验证,非常影响大家体验,不得不自己造数据。为了免于自己一个一个弄1.in,2.in...... ,去向deepseek学习了一下怎么一次性生成很多数据到一个包里。
主程序
cpp
//cr.cpp 主程序
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define fi first
#define se second
#define ps push_back
#define mk make_pair
const int N=2e5+10,inf=0x3f3f3f3f,mod=1e9+7;
inline ll read(){
char c=getchar();ll x=0;bool f=0;
while(!isdigit(c))f=c=='-'?1:0,c=getchar();
while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
return f?-x:x;
}
int main(){
for(int i=1;i<=5;++i){
string s=".\\rd data1\\"+to_string(i)+".in 1 5";system(s.c_str());
s=".\\1 data1\\"+to_string(i)+".in data1\\"+to_string(i)+".out";system(s.c_str());
}
for(int i=6;i<=20;++i){
string s=".\\rd data1\\"+to_string(i)+".in 200 100000";system(s.c_str());
s=".\\1 data1\\"+to_string(i)+".in data1\\"+to_string(i)+".out";system(s.c_str());
}
for(int i=21;i<=25;++i){
string s=".\\rd data1\\"+to_string(i)+".in 100000 100000";system(s.c_str());
s=".\\1 data1\\"+to_string(i)+".in data1\\"+to_string(i)+".out";system(s.c_str());
}
}
随机生成
cpp
//rd.cpp 用于生成数据
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define fi first
#define se second
#define ps push_back
#define mk make_pair
const int N=2e5+10,inf=0x3f3f3f3f,mod=1e9+7;
inline ll read(){
char c=getchar();ll x=0;bool f=0;
while(!isdigit(c))f=c=='-'?1:0,c=getchar();
while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
return f?-x:x;
}
mt19937 rd(time(0));
#define rd(l,r) (rd()%(r-l+1)+l)
int main(int argc,char* argv[]){
int l=stoi(argv[2]),r=stoi(argv[3]);
freopen(argv[1],"w",stdout);
cout<<rd(l,r)<<' '<<rd(l,r)<<' '<<rd(0,mod-1)<<' '<<rd(1,mod-7);
}
其中一些知识点
-
rd.cpp里main函数里传了一些参数, argc 表示命令中传了几个参,如
.\rd.cpp 1.out 2 3,就传了四个参,分别是.\rd.cpp,1.out,2,3,即 argc=4, argv则是字符串指针数组,argv0指向第一个参数,argv1指向第二个参数,这样可以通过argv来把参数直接传进来 -
stoi()是直接将字符串转化为int类型
-
c_str()是将string类型转化为char类型,保证系统能读懂,因为system命令里只能用char
比如主程序给出的第一句命令就是 .\rd data1\1.in 1 5
最后,通过上面的主程序,就可以直接生成大量的数据进入一个包里,省去了暴力组包的麻烦。