数据生成器求调
查看原帖
数据生成器求调
1278453
woshi_uid_813622楼主2024/3/12 19:24
/****************************************
作者:
版权:
日期:
*****************************************/
#include<bits/stdc++.h>
#define LL k<<1
#define RR k<<1|1
#define int long long

using namespace std;
mt19937 dbw(time(0));//只是一个随机数函数,请不要对号入座
int n, m;
char y[] = {'a', 'e', 'i', 'o', 'u'};
vector<string>a[101], x;
signed main() {
//	ios::sync_with_stdio(0);
//	freopen("read.in", "w", stdout);
	n = dbw() % 10 + 1;
	m = dbw() % 20 + 1;
	cout << n << ' ' << m << '\n';
	//生成习语并拆分字节
	for (int i = 1; i <= n; i++) {
		string s = "", t = "";
		if (i > 1) { //加强数据强度
			int si = dbw() % i + 1;
			int sj = dbw() % (a[si].size());
			a[i].push_back(a[si][sj]);
		}
		for (int len = 1; len <= dbw() % 10; len++) {
			char c = char(dbw() % 26 + 97);
			t += c; //用于记录
			if (c == 'n') {
				if(s.size())a[i].push_back(s);
				bool b = dbw() % 2;
				int yy = dbw() % 5;
				string tmp="n";
				if (b) {
					tmp+=y[yy];
					a[i].push_back(tmp); //后面跟元音
					t += y[yy];
				} else a[i].push_back(tmp); //反之
				s = "";
				continue;
			}
			s += c;
			if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { //元音结束
				a[i].push_back(s);
				s = "";
			}
		}
		if (s.size()) { //如果最后没有元音
			int yy = dbw() % 5;
			a[i].push_back(s + y[yy]);
			t += y[yy];
			s = "";
		}
		x.push_back(t);
		cout << t << '\n';
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= dbw() % 9 + 1; j++) {
			int sj = dbw() % 3;
			if (!sj) { //三分之一的概率直接输出习语
				cout << x[dbw() % n];
			}
			if (sj == 1) {
				//输出部分习语
				int xi = dbw() % n+1;
				int xj = dbw() % a[xi].size();
				cout << a[xi][xj];
			}
			if (sj == 2) { //随意发挥
				string szm = "";
				for (int k = 1; k <= dbw() % 5; k++) {
					char c = char(dbw() % 26 + 97);
					szm += c;
					if (c == 'n') {
						bool b = dbw() % 2;
						int yy = dbw() % 5;
						if (b) {
							szm+=y[yy];
						}
						continue;
					}
				}
				cout<<szm;
			}
		}
		cout<<'\n';
	}
	return 0;
}

我想写一个 这道题 的数据生成器,来帮可爱的 LH 对拍,但是 RE 了,帮忙看看

2024/3/12 19:24
加载中...