#include
#include
#include
using namespace std;
void merge(vector
//defining well named variables
int range = r - p + 1;
int lowHalf = q - p + 1;
int highHalf = r - q;
int rStart = q + 1;
int rEnd = r;
int lStart = p;
int lEnd = q;
//filling temp array
std::vector
for (int i = 0; i < range; i++) {
temp.push_back(a[lStart + i]);
}
//mergin subarrays
int left = lStart;
int right = rStart;
int k = 0; //index
while( (left <= lEnd) && (right <= rEnd)) {
if(a[left] <= a[right]) {
temp[k] = a[left];
left++;
} else {
temp[k] = a[right];
right++;
}
k++;
}
//coping rest of subarrays
while (right <= rEnd) {temp[k++] = a[right++];}
while (left <= rEnd) {temp[k++] = a[left++];}
//coping temp array to origin
for (int i = 0; i < range; i++) {
a[lStart + i] = temp[i];
}
}
void mergeSortRec(vector
int p;
if(l < r) {
p = (l+r)/2;
mergeSortRec(arr, l, p);
mergeSortRec(arr, p+1, r);
merge(arr, l,p, r);
}
}
void mergeSortIter(vector
int n = r - l - 1;
int size;
int start;
for (size = 1; size <= n; size *= 2) {
for (start = 0; start < n; start += 2*size) {
//index of left end
int mid = start + size - 1;
//are we out of the bound?
int end = min(start + 2*size - 1, n);
merge(arr, start, mid, end);
}
}
}
void merge_sort_time(vector
auto start = chrono::high_resolution_clock::now();
mergeSortRec(v,0,v.size()-1);
auto end = chrono::high_resolution_clock::now();
chrono::duration
std::cout << elapsed.count() << endl;
}
auto main(int argc, char const *argv[]) -> int
{
ios_base::sync_with_stdio(false);
int x;
vector
// getting inputs
while(cin >> x)
{
v.push_back(x);
cin.clear();
cin.sync();
std::cout << "One" << '\n';
}
// vector
// printVector(sorted);
merge_sort_time(v);
}