├── .gitignore ├── outputmaker.cpp ├── inputmaker.cpp └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | *.in 3 | *.out 4 | *.exe -------------------------------------------------------------------------------- /outputmaker.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define ll long long 3 | 4 | using namespace std; 5 | 6 | ifstream in; 7 | ofstream out; 8 | string indir = "../testdata/00_"; //input path 9 | string outdir = "../testdata/00_";//output path 10 | int fileId = 0; 11 | 12 | void start() { // 建立檔案 13 | while(1) { 14 | string filename; 15 | if (fileId < 10) 16 | filename += "0"; 17 | filename += to_string(fileId); 18 | in.open(outdir + filename + ".out"); 19 | fileId++; 20 | cerr << filename << endl; 21 | if (!in.is_open()) 22 | { 23 | out.open(outdir + filename + ".out"); 24 | in.open(indir + filename + ".in"); 25 | break; 26 | } 27 | else 28 | in.close(); 29 | } 30 | } 31 | 32 | #define MAKE 1 33 | #define cin in 34 | #if MAKE 35 | #define cout out 36 | #endif 37 | 38 | /************************************ solution space ************************************/ 39 | 40 | 41 | 42 | 43 | 44 | /************************************ solution space ************************************/ 45 | 46 | int main() 47 | { 48 | int N = 0; // number of input data 49 | // cin >> n; 50 | while (N--) 51 | { 52 | start(); 53 | int t = 1; 54 | 55 | while (t--) 56 | sol(); 57 | out.close(); 58 | in.close(); 59 | } 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /inputmaker.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define ll long long 3 | 4 | using namespace std; 5 | 6 | ifstream ifs; 7 | ofstream file; 8 | string dir_name = "../testdata";//path 9 | 10 | int fileId = 0; 11 | 12 | void make_file() { // 建立檔案 13 | int sum = 0, cnt = 0; 14 | while (1) { 15 | string filename; 16 | if (fileId < 10) 17 | filename += "0"; 18 | filename += to_string(fileId); 19 | cerr << filename << endl; 20 | ifs.open(dir_name + filename + ".in"); 21 | if (!ifs.is_open()) { 22 | file.open(dir_name + filename + ".in"); 23 | fileId++; 24 | break; 25 | } 26 | 27 | ifs.close(); 28 | fileId++; 29 | } 30 | } 31 | random_device rd; 32 | auto tt = chrono::high_resolution_clock::now(); 33 | std::mt19937_64 gen = std::mt19937_64(tt.time_since_epoch().count()); 34 | std::uniform_int_distribution<> dis_int(1, 2000000000); 35 | auto randint = bind(dis_int, gen); 36 | 37 | std::uniform_real_distribution<> dis_float(0, 1); 38 | auto randfloat = bind(dis_float, gen); 39 | 40 | 41 | #define MAKE 1 42 | #if MAKE 43 | #define cout file 44 | #endif 45 | 46 | void make() { 47 | 48 | } 49 | 50 | int main() 51 | { 52 | int N = 20; 53 | while (N--) { 54 | make_file(); 55 | int t = 1; 56 | while (t--) 57 | make(); 58 | file.close(); 59 | } 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Testdata-Maker 2 | 測資生成器 3 | 4 | ## 簡介 5 | 6 | 本生成器可以幫助您快速的生成比賽所需的 input/output 檔 7 | 8 | 9 | ## `inputmaker.cpp` 10 | 11 | ### 主要設定 12 | 13 | #### `dir_name` 14 | 15 | 設定輸入檔資料夾路徑 16 | 17 | #### `fileId` 18 | 19 | 代表目前建立到編號為 `fileId - 1` 的輸入檔 20 | 21 | #### `MAKE` 22 | 23 | 若定義 `MAKE = 1` 則代表目前要進行測資生成,使用 `cout` 將直接進行檔案寫入 24 | 25 | #### `N` 26 | 27 | 生成的檔案數量 28 | 29 | ### 主要函式 30 | 31 | #### `start()` 32 | 33 | 本函式會自動搜尋 `dir_name` 所指向資料夾中的 `.in` 檔案,並且自動偵測並建立 `.in` 檔,其檔名為未被建立的編號中的最小編號,例如目前資料夾中有 `00.in`, `01.in`, `02.in`, `03.in`,那麼程式便會自動生成 `04.in` 34 | 35 | #### `randint()` 36 | 37 | 本函式提供一個隨機的整數 38 | 39 | #### `randfloat()` 40 | 41 | 本函式提供一個隨機的浮點數 42 | 43 | #### `make()` 44 | 45 | 本函式為此程式的核心函式,程式將在此處理測資檔的生成 46 | 以下是一支生成長度 $\le$ 100 且元素 $< 10^9$ 的正整數數列的參考程式: 47 | 48 | ```cpp 49 | void make() { 50 | int n = randint() % 100 + 1; 51 | cout << n << endl; 52 | for (int i = 0; i < n; i++) { 53 | cout << randint() % (int)(1e9) << " "; 54 | } 55 | cout << endl; 56 | } 57 | ``` 58 | 59 | ## `outputmaker.cpp` 60 | 61 | ### 主要設定 62 | 63 | #### `indir`、`outdir` 64 | 65 | 設定輸入測資以及所要生成的答案目標位置 66 | 67 | #### `MAKE` 68 | 69 | 若 `MAKE` = 1 則答案的輸出將直接寫入至 `outdir` 資料夾中 70 | 71 | #### `N` 72 | 73 | 測資數量 74 | 75 | ### 主要函式 76 | 77 | #### `start()` 78 | 79 | 同 `inpurmaker.cpp` 80 | 81 | #### `sol()` 82 | 83 | 程式預設的解答函式 84 | 85 | #### 其餘皆與 `inputmaker.cpp` 相似 86 | 87 | ### 使用方法 88 | 89 | 將官方解答的函式(系統預設將運行 `sol()`)放入 `solution space` 中,直接運行將可得 `N` 筆答案 --------------------------------------------------------------------------------