Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- const int maxn = 100000 + 100;
- const int testCases = 50;
- int n;
- int num[maxn];
- ofstream fout;
- string numToStr(int x) {
- string str;
- while (x != 0) {
- str = char('0' + x % 10) + str;
- x /= 10;
- }
- return str;
- }
- string getFileInName(int index) {
- return "data/" + numToStr(index) + ".in";
- }
- string getFileOutName(int index) {
- return "data/" + numToStr(index) + ".out";
- }
- LL getRand(LL l, LL r) {
- LL rnd = rand();
- rnd = (rnd << 15) | rand();
- rnd = (rnd << 15) | rand();
- rnd = (rnd << 15) | rand();
- return rnd % (r - l + 1) + l;
- }
- void output(int fileIdx) {
- string fileInName = getFileInName(fileIdx);
- fout.open(fileInName);
- fout << n << endl;
- for (int i = 1; i <= n; ++i) {
- if (i != 1) {
- fout << " ";
- }
- fout << num[i];
- }
- fout << endl;
- fout.close();
- string fileOutName = getFileOutName(fileIdx);
- system(("std.exe < " + fileInName + " > " + fileOutName).c_str());
- }
- void genData(int n, int l, int r) {
- for (int i = 1; i <= n; ++i) {
- num[i] = getRand(l, r);
- }
- }
- void writeToFile(int from, int to, int nl, int nr) {
- int e9 = 1000000000;
- n = getRand(nl, nr);
- genData(n, 1, e9);
- output(from);
- n = getRand(nl, nr);
- genData(n, -e9, -1);
- output(from + 1);
- n = getRand(nl, nr);
- genData(n, -e9, e9);
- output(from + 2);
- for (int i = from + 3; i <= to; ++i) {
- n = getRand(nl, nr);
- genData(n, -e9, e9);
- output(i);
- }
- }
- int main() {
- ios::sync_with_stdio(false);
- srand(time(0));
- // data in 60%, 1 <= n <= 1000
- int one = testCases * 60 / 100;
- writeToFile(1, one, 1, 1000);
- // data in 100%, 1 <= n <= 100000
- writeToFile(one + 1, testCases, 90000, 100000);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment