Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include".\template\headers.hpp"
- // #define MULTI_TASKCASE
- using namespace abb;
- using namespace output;
- using namespace rit;
- using namespace wit;
- inline void init() {
- }
- constexpr int n = 1e5;
- void merge_sort(A<int, n>& arr, int l = 0, int r = n) {
- if (r - l < 2) return;
- static A<int, n> tmp;
- int m = (l + r) >> 1;
- merge_sort(arr, l, m);
- merge_sort(arr, m, r);
- auto t = tmp.begin(), a = arr.begin();
- copy(a + l, a + m, t + l);
- copy(a + m, a + r, t + m);
- int i = l, lp = l, rp = m;
- while (lp < m && rp < r) {
- if (t[lp] < t[rp])
- a[i++] = t[lp++];
- else
- a[i++] = t[rp++];
- }
- while (lp < m)
- a[i++] = t[lp++];
- while (rp < r)
- a[i++] = t[rp++];
- }
- inline void solve() {
- static A<int, n> v;
- A<double, 20> arr;
- fstream filein("in.txt", ios::in);
- cin.rdbuf(filein.rdbuf());
- for (auto& k : arr) {
- cout << "poop" << ' ';
- for (auto& i : v)
- cin >> i;
- clock_t before = clock();
- merge_sort(v);
- clock_t after = clock();
- k = double(after - before) / CLOCKS_PER_SEC * 1000;
- }
- filein.close();
- cout << endl << flush;
- fstream fileout("out.txt", ios::out);
- cout.rdbuf(fileout.rdbuf());
- for (int i = 0; i != 20; i++)
- cout << arr[i] << endl;
- fileout.close();
- }
- main() {
- ios::sync_with_stdio(false);
- init();
- int t = 1;
- #ifdef MULTI_TASKCASE
- cin >> t; cin.ignore();
- #endif
- while (t--) solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment