Advertisement
Saleh127

Test case generated code

Oct 11th, 2021
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define all(x) (x).begin(), (x).end()
  3. using namespace std;
  4. typedef unsigned long long ull;
  5. typedef long long ll;
  6. typedef long double ld;
  7. typedef pair<int, int> pii;
  8.  
  9. /// TODO: hack gp_hash_table
  10. /// TODO: write string & long double hacks
  11.  
  12. const int SEED = 10000;
  13.  
  14. //const int DEG = 444487; // ++17
  15. //const int DEG = 520241; // all other
  16.  
  17. //const int DEG = 256279; // C++11, 14, 17-x64, 17 (tr1::)
  18. const int DEG = 218971; // C++17
  19. //const int DEG = 202409; // for reserved 2e5
  20. //const int DEG = 410857; // for reserved 4e5
  21. //const int DEG = 262144; // for MSVC++17
  22. //const int DEG = 1142821; // special bonus
  23.  
  24. int cur = 0;
  25. int nxt() {
  26.     cur += DEG;
  27.     if (cur >= int(1e9))
  28.         cur = (cur % DEG) + 1;
  29.     return cur;
  30. }
  31.  
  32. int comp(int a, int b) {
  33.     return a % DEG == b % DEG ? a / DEG > b / DEG : a % DEG > b % DEG;
  34. }
  35.  
  36. int main() {
  37.     ios::sync_with_stdio(false);
  38.     cin.tie(nullptr);
  39.    
  40.     constexpr int n = 199999;
  41.     mt19937 gen(SEED);
  42.     int skip = uniform_int_distribution<>(1, 1000000)(gen);
  43.     while (skip--)
  44.         nxt();
  45.     vector<int> v;
  46.     cout << 1 << "\n" << n << "\n";
  47.     ll sum = 0;
  48.     for (int i = 0; v.size() < n && i < n; ++i) {
  49.         int cur;
  50.         cur = nxt();
  51.         //do cur = nxt() * 412705471LL; while (cur < 0 || cur > (int)1e9);
  52.         if (i == n-1)
  53.             cur = n - sum % n;
  54.         sum += cur;
  55.         v.push_back(cur);
  56.         swap(v[i], v[uniform_int_distribution<>(0, i)(gen)]);
  57.     }
  58.     //sort(all(v));
  59.     //reverse(all(v));
  60.     for (int i = 0; i < n; ++i)
  61.         cout << (i ? " " : "") << v[i];
  62.     cout << endl;
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement