Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 20.17 KB | None | 0 0
  1. #include <stdexcept>
  2. #include <iostream>
  3. #include <vector>
  4. #include <fstream>
  5. #include <algorithm>
  6. #include <set>
  7. #include <array>
  8. #include <random>
  9. #include <time.h>
  10.  
  11. size_t MEMORY = 8 * 10000;
  12.  
  13. size_t int_size = 4;
  14.  
  15.  
  16. void SortChunks(std::istream& stream, size_t chunk_count, size_t chunk_elem_count,
  17.                 size_t all_elem_count, size_t sorting_index, size_t one_element_count) {
  18.     std::vector<std::array<int32_t, 3>> chunk(chunk_elem_count);
  19.  
  20.     auto current_size = (int)all_elem_count;
  21.     for (size_t i = 0; i < chunk_count; ++i) {
  22.         int64_t min_element = std::min((int)chunk_elem_count, current_size);
  23.  
  24.         for (size_t j = 0; j < min_element; ++j) {
  25.             for (size_t k = 0; k < one_element_count; ++k) {
  26.                 int32_t value;
  27.                 stream.read((char*) &value, int_size);
  28.                 chunk[j][k] = value;
  29.             }
  30.         }
  31.  
  32.         current_size -= chunk_elem_count;
  33.         chunk.resize(min_element);
  34.         auto sort_compare = [sorting_index](const std::array<int32_t, 3>& lhs, const std::array<int32_t, 3>& rhs) {
  35.             return lhs[sorting_index] < rhs[sorting_index];
  36.         };
  37.         std::sort(chunk.begin(), chunk.end(), sort_compare);
  38.  
  39.         std::ofstream out_chunk("chunk" + std::to_string(i),  std::ios::binary| std::ios::out);
  40.         out_chunk.write((char*)&min_element, int_size);
  41.         for (size_t j = 0; j < min_element; ++j) {
  42.             for (size_t k = 0; k < one_element_count; ++k) {
  43.                 out_chunk.write((char *) &chunk[j][k], int_size);
  44.             }
  45.         }
  46.     }
  47. }
  48.  
  49. void MergeChunks(int64_t all_elem_count, size_t chunk_count,
  50.                  const std::string& outputFile, size_t sorting_index,
  51.                  size_t one_element_count) {
  52.     std::ofstream out_chunk(outputFile, std::ios::binary| std::ios::out);
  53.     out_chunk.write((char*)&all_elem_count, int_size);
  54.  
  55.     std::vector<std::ifstream> streams;
  56.     std::vector<size_t> streams_size;
  57.     std::vector<size_t> streams_counter;
  58.  
  59.     auto comparator = [sorting_index](const std::pair<std::array<int32_t, 3>, size_t>& first,
  60.                                       const std::pair<std::array<int32_t, 3>, size_t>& second) {
  61.         return first.first[sorting_index] < second.first[sorting_index];
  62.     };
  63.  
  64.     std::set<std::pair<std::array<int32_t, 3>, size_t>,
  65.             decltype(comparator)> for_merge(comparator);
  66.  
  67.     for (size_t i = 0; i < chunk_count; ++i) {
  68.         streams.emplace_back("chunk" + std::to_string(i), std::ios::binary);
  69.  
  70.         int32_t chunk_size;
  71.  
  72.         streams.back().read((char*) &chunk_size, int_size);
  73.         streams_size.push_back((size_t)chunk_size);
  74.  
  75.         std::array<int32_t, 3> chunk_values;
  76.         for (size_t j = 0; j < one_element_count; ++j) {
  77.             int32_t value;
  78.             streams.back().read((char*) &value, int_size);
  79.             chunk_values[j] = value;
  80.         }
  81.  
  82.         for_merge.insert(std::make_pair(chunk_values, i));
  83.         streams_counter.push_back(0);
  84.     }
  85.  
  86.     for (size_t i = 0; i < all_elem_count; ++i) {
  87.         auto min = for_merge.begin();
  88.         auto current_value = min->first;
  89.         auto chunk_id = min->second;
  90.  
  91.         for_merge.erase(min);
  92.         ++streams_counter[chunk_id];
  93.  
  94.         for (size_t j = 0; j < one_element_count; ++j) {
  95.             out_chunk.write((char*)&current_value[j], int_size);
  96.         }
  97.  
  98.         if (streams_size[chunk_id] > streams_counter[chunk_id]) {
  99.             std::array<int32_t, 3> chunk_values;
  100.             for (size_t j = 0; j < one_element_count; ++j) {
  101.                 int32_t value;
  102.                 streams[chunk_id].read((char*) &value, int_size);
  103.                 chunk_values[j] = value;
  104.             }
  105.  
  106.             for_merge.insert(std::make_pair(chunk_values, chunk_id));
  107.         }
  108.     }
  109. }
  110.  
  111. void ExternalSort(const std::string& inputFile, const std::string& outputFile,
  112.                   size_t one_element_count, size_t sorting_index) {
  113.     std::ifstream data(inputFile, std::ios::binary);
  114.  
  115.     int32_t n;
  116.     data.read((char*) &n, int_size);
  117.     int32_t fileSize = n * 2 * int_size;
  118.     size_t chunk_count = fileSize / MEMORY;
  119.     if (fileSize % MEMORY) {
  120.         ++chunk_count;
  121.     }
  122.  
  123.     size_t chunk_elem_count;
  124.     if (fileSize < MEMORY) {
  125.         chunk_elem_count = n;
  126.     } else {
  127.         chunk_elem_count = MEMORY / (2 * int_size);
  128.     }
  129.  
  130.     SortChunks(data, chunk_count, chunk_elem_count,
  131.                n, sorting_index, one_element_count);
  132.     MergeChunks(n, chunk_count, outputFile,
  133.                 sorting_index, one_element_count);
  134. }
  135.  
  136.  
  137. void GenFromVector(const std::vector<int32_t>& numbers, const std::string& fileName) {
  138.     std::ofstream outfile(fileName, std::ios::binary| std::ios::out);
  139.     int32_t n = numbers.size() /  2;
  140.     outfile.write((char*)& n, int_size);
  141.     for(size_t i = 0; i < numbers.size(); ++i) {
  142.         outfile.write((char*)&numbers[i], int_size);
  143.     }
  144.     outfile.close();
  145. }
  146.  
  147. void EvaluateRandomMarks(const std::string& input, const std::string& output) {
  148.     ExternalSort(input, "sorted_0_" + input, 2, 0);
  149.     std::ifstream infile("sorted_0_" + input, std::ios::binary);
  150.     std::ofstream outfile(output, std::ios::binary);
  151.  
  152.     int32_t n;
  153.     infile.read((char*) &n, int_size);
  154.     outfile.write((char *) &n, int_size);
  155.  
  156.     std::mt19937 rng;
  157.     rng.seed(std::random_device()());
  158.     std::uniform_int_distribution<std::mt19937::result_type> dist(0, 1);
  159.  
  160.     for (size_t i = 0; i < n; ++i) {
  161.         int32_t value1, value2;
  162.         infile.read((char*) &value1, int_size);
  163.         infile.read((char*) &value2, int_size);
  164.  
  165.  
  166.         int32_t random_mark = (int32_t)dist(rng);
  167.         if (i == 0) {
  168.             random_mark = 1;
  169.         }
  170.         outfile.write((char *) &value1, int_size);
  171.         outfile.write((char *) &random_mark, int_size);
  172.     }
  173. }
  174.  
  175. void JoinMarks1(const std::string& input,
  176.                 const std::string& marks,
  177.                 const std::string& output,
  178.                 bool need_3) {
  179.     std::ifstream infile(input, std::ios::binary);
  180.     std::ifstream marks_infile(marks, std::ios::binary);
  181.     std::ofstream outfile(output, std::ios::binary);
  182.  
  183.     int32_t n;
  184.     infile.read((char*) &n, int_size);
  185.     marks_infile.read((char*) &n, int_size);
  186.     outfile.write((char *) &n, int_size);
  187.  
  188.     for (size_t i = 0; i < n; ++i) {
  189.         int32_t x1, x2;
  190.         infile.read((char*) &x1, int_size);
  191.         infile.read((char*) &x2, int_size);
  192.  
  193.         int32_t y1, y2;
  194.         marks_infile.read((char*) &y1, int_size);
  195.         marks_infile.read((char*) &y2, int_size);
  196.  
  197.         outfile.write((char *) &x1, int_size);
  198.         if (need_3) {
  199.             outfile.write((char *) &x2, int_size);
  200.         }
  201.         outfile.write((char *) &y2, int_size);
  202.     }
  203. }
  204.  
  205. bool JoinMarks2(const std::string& input, const std::string& marks, const std::string& output) {
  206.     std::ifstream infile(input, std::ios::binary);
  207.     std::ifstream marks_infile(marks, std::ios::binary);
  208.     std::ofstream outfile(output, std::ios::binary);
  209.  
  210.     int32_t n;
  211.     infile.read((char*) &n, int_size);
  212.     marks_infile.read((char*) &n, int_size);
  213.     outfile.write((char *) &n, int_size);
  214.  
  215.     size_t counter = 0;
  216.     for (size_t i = 0; i < n; ++i) {
  217.         int32_t x1, x2;
  218.         infile.read((char*) &x1, int_size);
  219.         infile.read((char*) &x2, int_size);
  220.  
  221.         int32_t y1, y2;
  222.         marks_infile.read((char*) &y1, int_size);
  223.         marks_infile.read((char*) &y2, int_size);
  224.  
  225.         outfile.write((char *) &x1, int_size);
  226.  
  227.         int32_t mark_for_write;
  228.         if (x2 == 0 && y2 == 1) {
  229.             mark_for_write = 0;
  230.             counter++;
  231.         } else {
  232.             mark_for_write = 1;
  233.         }
  234.         outfile.write((char *) &mark_for_write, int_size);
  235.     }
  236.     return (counter != 0);
  237. }
  238.  
  239. size_t JoinMarks3(const std::string& in_current_marks,
  240.                 const std::string& in_next_marks,
  241.                 const std::string& output) {
  242.     std::ifstream current_marks(in_current_marks, std::ios::binary);
  243.     std::ifstream next_marks(in_next_marks, std::ios::binary);
  244.     std::ofstream outfile(output, std::ios::binary);
  245.  
  246.     int32_t n;
  247.     current_marks.read((char*) &n, int_size);
  248.     next_marks.read((char*) &n, int_size);
  249.     outfile.write((char *) &n, int_size);
  250.  
  251.     size_t size_counter = 0;
  252.     for (size_t i = 0; i < n; ++i) {
  253.         int32_t x1, x2;
  254.         current_marks.read((char*) &x1, int_size);
  255.         current_marks.read((char*) &x2, int_size);
  256.  
  257.         int32_t y1, y2;
  258.         next_marks.read((char*) &y1, int_size);
  259.         next_marks.read((char*) &y2, int_size);
  260.  
  261.         if (x2 == 1) {
  262.             ++size_counter;
  263.         }
  264.  
  265.         int32_t mark_for_write = x2 + 2 * y2;
  266.         outfile.write((char *) &x1, int_size);
  267.         outfile.write((char *) &mark_for_write, int_size);
  268.     }
  269.     return size_counter;
  270. }
  271.  
  272.  
  273. void JoinMarks4(const std::string& in_next_next,
  274.                 const std::string& in_marks,
  275.                 const std::string& output,
  276.                 int32_t size_new_list) {
  277.     std::ifstream next_next(in_next_next, std::ios::binary);
  278.     std::ifstream marks(in_marks, std::ios::binary);
  279.     std::ofstream outfile(output, std::ios::binary);
  280.  
  281.     int32_t n;
  282.     next_next.read((char*) &n, int_size);
  283.     marks.read((char*) &n, int_size);
  284.     outfile.write((char *) &size_new_list, int_size);
  285.  
  286.     for (size_t i = 0; i < n; ++i) {
  287.         int32_t x1, x2, x3;
  288.         next_next.read((char*) &x1, int_size);
  289.         next_next.read((char*) &x2, int_size);
  290.         next_next.read((char*) &x3, int_size);
  291.  
  292.         int32_t y1, y2;
  293.         marks.read((char*) &y1, int_size);
  294.         marks.read((char*) &y2, int_size);
  295.  
  296.         if (y2 % 2 == 1) {
  297.             int32_t next_id;
  298.             next_id = (y2 == 1) ? x3 : x2;
  299.             outfile.write((char *) &x1, int_size);
  300.             outfile.write((char *) &next_id, int_size);
  301.         }
  302.     }
  303. }
  304.  
  305.  
  306. bool FixRandomMarks(const std::string& input, const std::string& random_marks, const std::string& output) {
  307.     ExternalSort(input, "sorted_1_" + input, 2, 1);
  308.  
  309.     JoinMarks1("sorted_1_" + input, random_marks, "joined_next_" + random_marks, false);
  310.     ExternalSort("joined_next_" + random_marks, "sorted_joined_next_" + random_marks, 2, 0);
  311.  
  312.     return JoinMarks2(random_marks, "sorted_joined_next_" + random_marks, output);
  313. }
  314.  
  315.  
  316. std::string EvaluateMarks(const std::string& input, int recursive_depth) {
  317.     std::string random_marks_file_name = "random_marks_" + std::to_string(recursive_depth);
  318.     std::string fixed_marks_file_name = "marks_" + std::to_string(recursive_depth);
  319.  
  320.     bool is_changed = false;
  321.     while (!is_changed) {
  322.         EvaluateRandomMarks(input, random_marks_file_name);
  323.         is_changed = FixRandomMarks(input, random_marks_file_name, fixed_marks_file_name);
  324.     }
  325.     return fixed_marks_file_name;
  326. }
  327.  
  328.  
  329. size_t JoinCurrentNextMarks(const std::string& input,
  330.                           const std::string& marks_file_name,
  331.                           const std::string& output) {
  332.     JoinMarks1("sorted_1_" + input, marks_file_name, "joined_next_" + marks_file_name, false);
  333.     ExternalSort("joined_next_" + marks_file_name, "sorted_joined_next_" + marks_file_name, 2, 0);
  334.     size_t size_new_list = JoinMarks3(marks_file_name, "sorted_joined_next_" + marks_file_name, output);
  335.  
  336.     return size_new_list;
  337. }
  338.  
  339. void JoinNextNext(const std::string& input, const std::string& output) {
  340.     JoinMarks1("sorted_1_" + input, "sorted_0_" + input, output, true);
  341. }
  342.  
  343. void JoinNewList(const std::string& current_next_marks,
  344.                  const std::string& next_next,
  345.                  const std::string& output,
  346.                  size_t size_new_list) {
  347.     ExternalSort(next_next, "sorted_0_" + next_next, 3, 0);
  348.     JoinMarks4("sorted_0_" + next_next, current_next_marks, output, size_new_list);
  349. }
  350.  
  351. std::string EvaluateNewList(const std::string& input,
  352.                             const std::string& marks_file_name,
  353.                             int recursive_depth,
  354.                             size_t& size_new_list) {
  355.     std::string current_next_marks = "current_next_" + marks_file_name;
  356.     std::string next_next = "next_next_" + std::to_string(recursive_depth);
  357.     std::string new_list = "new_list_" + std::to_string(recursive_depth);
  358.  
  359.     size_t size_new = JoinCurrentNextMarks(input, marks_file_name, current_next_marks);
  360.     size_new_list = size_new;
  361.  
  362.     JoinNextNext(input, next_next);
  363.     JoinNewList(current_next_marks, next_next, new_list, size_new_list);
  364.  
  365.     return new_list;
  366. }
  367.  
  368. void Join5(const std::string& current_weight_file_name,
  369.            const std::string& marks_file_name,
  370.            const std::string& output,
  371.            size_t size_new_list) {
  372.     std::ifstream current_weight("sorted_" + current_weight_file_name, std::ios::binary);
  373.     std::ifstream next_weight("sorted_joined_next_" + current_weight_file_name, std::ios::binary);
  374.     std::ifstream marks(marks_file_name, std::ios::binary);
  375.     std::ofstream outfile(output, std::ios::binary);
  376.  
  377.     int32_t n;
  378.     current_weight.read((char*) &n, int_size);
  379.     next_weight.read((char*) &n, int_size);
  380.     marks.read((char*) &n, int_size);
  381.     outfile.write((char *) &size_new_list, int_size);
  382.  
  383.     for (size_t i = 0; i < n; ++i) {
  384.         int32_t x1, x2;
  385.         current_weight.read((char*) &x1, int_size);
  386.         current_weight.read((char*) &x2, int_size);
  387.  
  388.         int32_t z1, z2;
  389.         next_weight.read((char*) &z1, int_size);
  390.         next_weight.read((char*) &z2, int_size);
  391.  
  392.         int32_t y1, y2;
  393.         marks.read((char*) &y1, int_size);
  394.         marks.read((char*) &y2, int_size);
  395.  
  396.         if (y2 % 2 == 1) {
  397.             int32_t new_weight;
  398.             new_weight = (y2 == 1) ? (x2 + z2) : x2;
  399.             outfile.write((char *) &x1, int_size);
  400.             outfile.write((char *) &new_weight, int_size);
  401.         }
  402.     }
  403. }
  404.  
  405.  
  406. void Join6(const std::string& input,
  407.            const std::string& result_file_name,
  408.            const std::string& marks_file_name,
  409.            const std::string& weight_file_name,
  410.            const std::string& output) {
  411.     std::ifstream sort_input(input, std::ios::binary);
  412.     std::ifstream marks(marks_file_name, std::ios::binary);
  413.     std::ifstream weigth(weight_file_name, std::ios::binary);
  414.     std::ifstream result(result_file_name, std::ios::binary);
  415.     std::ofstream outfile(output, std::ios::binary);
  416.  
  417.     int32_t n;
  418.     sort_input.read((char*) &n, int_size);
  419.     outfile.write((char *) &n, int_size);
  420.     marks.read((char*) &n, int_size);
  421.     result.read((char*) &n, int_size);
  422.     weigth.read((char*) &n, int_size);
  423.  
  424.  
  425.     for (size_t i = 0; i < n; ++i) {
  426.         int32_t x1, x2;
  427.         sort_input.read((char*) &x1, int_size);
  428.         sort_input.read((char*) &x2, int_size);
  429.  
  430.         int32_t z1, z2;
  431.         marks.read((char*) &z1, int_size);
  432.         marks.read((char*) &z2, int_size);
  433.  
  434.         int32_t w1, w2;
  435.         weigth.read((char*) &w1, int_size);
  436.         weigth.read((char*) &w2, int_size);
  437.  
  438.         if (z2 % 2 == 1) {
  439.             int32_t y1, y2;
  440.             result.read((char*) &y1, int_size);
  441.             result.read((char*) &y2, int_size);
  442.  
  443.             outfile.write((char *) &y1, int_size);
  444.             outfile.write((char *) &y2, int_size);
  445.  
  446.             if (z2 == 1) {
  447.                 int32_t s = y2 + w2;
  448.                 outfile.write((char *) &x2, int_size);
  449.                 outfile.write((char *) &s, int_size);
  450.             }
  451.         }
  452.     }
  453. }
  454.  
  455. std::string EvaluateWeight(const std::string& input,
  456.                            const std::string& marks_file_name,
  457.                            int recursive_depth,
  458.                            size_t size_new_list) {
  459.     std::string next_weight =  "weight_" + std::to_string(recursive_depth + 1);
  460.     std::string current_weight =  "weight_" + std::to_string(recursive_depth);
  461.  
  462.     ExternalSort(current_weight, "sorted_" + current_weight, 2, 0);
  463.     JoinMarks1("sorted_1_" + input, "sorted_" + current_weight, "joined_next_" + current_weight, false);
  464.     ExternalSort("joined_next_" + current_weight, "sorted_joined_next_" + current_weight, 2, 0);
  465.  
  466.     Join5(current_weight,
  467.           "current_next_" + marks_file_name,
  468.           next_weight,
  469.           size_new_list);
  470.     return next_weight;
  471. }
  472.  
  473. int32_t GetListSize(const std::string& input) {
  474.     std::ifstream list(input, std::ios::binary);
  475.     int32_t n;
  476.     list.read((char*) &n, int_size);
  477.     return n;
  478. }
  479.  
  480. void EvaluateRealRank(const std::string& input, const std::string& marks_file_name, int recursive_depth) {
  481.     ExternalSort("result_" + std::to_string(recursive_depth + 1),
  482.                  "sorted_result_" + std::to_string(recursive_depth + 1), 2, 0);
  483.  
  484.     Join6("sorted_0_" + input,
  485.           "sorted_result_" + std::to_string(recursive_depth + 1),
  486.           "current_next_" + marks_file_name,
  487.           "weight_" + std::to_string(recursive_depth),
  488.           "result_" + std::to_string(recursive_depth));
  489. }
  490.  
  491. void CreateSimpleList(int recursive_depth) {
  492.     std::ifstream input("weight_" +  std::to_string(recursive_depth), std::ios::binary);
  493.     std::ofstream outfile("result_" + std::to_string(recursive_depth), std::ios::binary);
  494.  
  495.     int32_t n;
  496.     input.read((char*) &n, int_size);
  497.     outfile.write((char *) &n, int_size);
  498.  
  499.     int32_t x1, x2, zero = 0;
  500.     input.read((char*) &x1, int_size);
  501.     input.read((char*) &x2, int_size);
  502.  
  503.     outfile.write((char *) &x1, int_size);
  504.     outfile.write((char*) &zero, int_size);
  505.  
  506.  
  507.     int32_t y1, y2;
  508.     input.read((char*) &y1, int_size);
  509.     input.read((char*) &y2, int_size);
  510.  
  511.     outfile.write((char *) &y1, int_size);
  512.     outfile.write((char*) &x2, int_size);
  513. }
  514.  
  515.  
  516. void EvaluateRanks(const std::string& input, int recursive_depth) {
  517.     auto list_size = GetListSize(input);
  518.  
  519.     if (list_size <= 2) {
  520.         CreateSimpleList(recursive_depth);
  521.         return;
  522.     }
  523.  
  524.     size_t size_new_list;
  525.     auto marks_file_name = EvaluateMarks(input, recursive_depth);
  526.     auto new_list_file_name = EvaluateNewList(input, marks_file_name, recursive_depth, size_new_list);
  527.     auto weight_file_name = EvaluateWeight(input, marks_file_name, recursive_depth, size_new_list);
  528.  
  529.     EvaluateRanks(new_list_file_name, recursive_depth + 1);
  530.  
  531.     EvaluateRealRank(input, marks_file_name, recursive_depth);
  532. }
  533.  
  534.  
  535. void GenerateStartingWeight(const std::string& input) {
  536.     std::ifstream infile(input, std::ios::binary);
  537.     std::ofstream outfile("weight_0", std::ios::binary);
  538.  
  539.     int32_t n;
  540.     infile.read((char*) &n, int_size);
  541.     outfile.write((char *) &n, int_size);
  542.  
  543.     for (size_t i = 0; i < n; ++i) {
  544.         int32_t x1, x2;
  545.         infile.read((char*) &x1, int_size);
  546.         infile.read((char*) &x2, int_size);
  547.  
  548.         int32_t weight = 1;
  549.         outfile.write((char *) &x1, int_size);
  550.         outfile.write((char *) &weight, int_size);
  551.     }
  552. }
  553.  
  554. void PostProcess(const std::string& input, const std::string& output) {
  555.     ExternalSort(input, "sorted_" + input, 2, 1);
  556.     std::ifstream infile("sorted_" + input, std::ios::binary);
  557.     std::ofstream outfile(output, std::ios::binary);
  558.  
  559.     int32_t n;
  560.     infile.read((char*) &n, int_size);
  561.  
  562.     for (size_t i = 0; i < n; ++i) {
  563.         int32_t x1, x2;
  564.         infile.read((char*) &x1, int_size);
  565.         infile.read((char*) &x2, int_size);
  566.  
  567.         outfile.write((char *) &x1, int_size);
  568.     }
  569. }
  570.  
  571. void ListRanking(const std::string& input, const std::string& output) {
  572.     GenerateStartingWeight(input);
  573.     EvaluateRanks(input, 0);
  574.     PostProcess("result_0", "output.bin");
  575. }
  576.  
  577. std::vector<int32_t> GenVector(int n) {
  578.     std::vector<int32_t> result;
  579.     for (int i = n; i > 0; --i) {
  580.         result.push_back(i);
  581.         result.push_back(i - 1);
  582.     }
  583.     result.push_back(0);
  584.     result.push_back(n);
  585.  
  586.     return result;
  587. }
  588.  
  589. int main() {
  590. //    std::vector<int32_t> nums = {4, 5, 5, 1, 1, 2, 3, 4, 2, 3,     7, 6, 8, 9, 11, 12,21 ,19, 45, 40};
  591. //    std::vector<int32_t> nums = {4, 5, 5, 1, 1, 2, 3, 4, 2, 3};
  592. //    std::vector<int32_t> nums = {3, 1, 1, 5, 5, 10, 10, 0,0, 3};
  593.     GenFromVector(GenVector(500000),"input.bin");
  594.  
  595.     clock_t tStart = clock();
  596.     ListRanking("input.bin", "output.bin");
  597.     std::cout << (double)(clock() - tStart) / CLOCKS_PER_SEC;
  598.     return 0;
  599. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement