Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //assume that rnd.next(a, b) returns a random number in the range [a, b]
- //assume that shuffle() shuffles the array uniformly and randomly
- //the generated data is written to stdout
- #include "testlib.h"
- #include <algorithm>
- #include <iostream>
- #include <cstdio>
- #include <vector>
- #include <cmath>
- #include <numeric>
- #include <functional>
- using namespace std;
- #define all(x) x.begin(), x.end()
- int main(int argc, char* argv[]) {
- registerGen(argc,argv,1);
- int n = atoi(argv[1]); //number of elements in array
- int q = atoi(argv[2]); //number of queries
- int rollback_count = atoi(argv[3]); //total amount of rollbacks
- int d = atoi(argv[4]); //maximum value of d
- int ai = atoi(argv[5]); //maximum value of an element in the array
- printf("%d %d\n", n, q);
- vector<int> does_rollback(q), perm(q);
- iota(all(perm), 0);
- shuffle(all(perm));
- for(int i = 0; i<rollback_count; i++){
- does_rollback[perm[i]] = 1;
- }
- for(int t = 1; t<=q; t++){
- int op = (does_rollback[t-1]) ? 2 : 1;
- int dd = rnd.next(1, d);
- if(op == 1){
- int l = rnd.next(1, n), r = rnd.next(1, n);
- if(l > r) swap(l, r);
- int x = rnd.next(1, ai);
- printf("%d %d %d %d %d\n", op, dd, l, r, x);
- }else{
- int k = rnd.next(0, t-1);
- printf("%d %d %d\n", op, dd, k);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement