fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include<bits/stdc++.h>
  6.  
  7. // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  8. // #define getrand(l, r) uniform_int_distribution<long long>(l, r)(rng)
  9.  
  10. using namespace std;
  11. const int N = 100000;
  12.  
  13. // Function to generate a random number between low and high inclusive
  14. int randInt(int low, int high) {
  15. return low + rand() % (high - low + 1);
  16. }
  17.  
  18. void generateTestCase(int fileIndex, int maxT, int maxN, int maxK, int maxQ) {
  19. // Open the output file
  20. ofstream outFile("out" + to_string(fileIndex) + ".txt");
  21.  
  22. // Generate the number of test cases (t)
  23. int t = randInt(1, maxT);
  24. outFile << t << endl;
  25.  
  26.  
  27. int totalQ = 0;
  28.  
  29. for (int i = 1; i < t; i++) {
  30. // Generate n, k, and q
  31. int n = randInt(1, maxN);
  32. int k = randInt(1, maxK);
  33. // int q;
  34. int q = randInt(1, min(maxQ, max(N / (t - i + 1),2))); // Ensure sum(q) ≤ 2 * 10^5
  35. while(q + totalQ > N){
  36.  
  37. q = randInt(1, min(N-totalQ, max(N / (t - i + 1),1))); // Ensure sum(q) ≤ 2 * 10^5
  38. // cout<<"LOOP"<<endl;
  39. // cout<<q<<endl;
  40. // cout<<totalQ<<endl;
  41. }
  42. totalQ += q;
  43. // cout<<totalQ<<endl;
  44. // totalQ += q;
  45.  
  46. // Output n, k, and q for this test case
  47. outFile << n << " " << k << " " << q << endl;
  48.  
  49. // Generate q queries
  50. for (int j = 0; j < q; j++) {
  51. // Generate n1, n2, k1, k2
  52. int n1 = randInt(1, n);
  53. int n2 = randInt(n1, n); // Ensure n1 ≤ n2
  54. int k1 = randInt(1, k);
  55. int k2 = randInt(k1, k); // Ensure k1 ≤ k2
  56.  
  57. // Output the query
  58. outFile << n1 << " " << k1 << " " << n2 << " " << k2 << endl;
  59. }
  60.  
  61. // Check if totalQ exceeds the limit and break if needed
  62. if (totalQ >= 2*N) {
  63. cout<<"break due to exeeding N"<<endl;
  64. break;
  65. }
  66. }
  67.  
  68. // Close the file
  69. outFile.close();
  70. }
  71.  
  72. int main() {
  73. srand(time(0)); // Seed for randomness
  74.  
  75. int numFiles = 5; // Number of output files
  76. int maxT = 10000; // Maximum number of test cases per file (t)
  77. int maxN = 1000; // Maximum value of n
  78. int maxK = 1000; // Maximum value of k
  79. int maxQ = 1000; // Maximum number of queries over all test cases
  80.  
  81. // Generate test files
  82. // for (int i = 1; i <= numFiles; i++) {
  83. // generateTestCase(i, maxT, maxN, maxK, maxQ);
  84. // }
  85. for (int i = numFiles+1; i <= 2*numFiles; i++) {
  86. generateTestCase(i, 2, 10, 5, 6);
  87. }
  88.  
  89. return 0;
  90. }
  91.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty