Submission #577882

#TimeUsernameProblemLanguageResultExecution timeMemory
577882mi_ni_Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; long long merge_util(vector<int> &arr, int l, int r) { int mid = (l+r)/2; long long cnt = 0; int it1 = l, it2 = mid+1; while(it2 <= r) { while(it1 <= mid && arr[it1] < arr[it2]) it1++; cnt += (mid+1-it1); it2++; } vector<int> temp(r-l+1); merge(arr.begin()+l, arr.begin()+mid+1, arr.begin()+mid+1, arr.begin()+r+1, temp.begin()); copy(temp.begin(), temp.end(), arr.begin()+l); return cnt; } long long find_inversions(vector<int> &arr, int l, int r) { if(r <= l) return 0ll; int mid = (l+r)/2; long long ans = find_inversions(arr, l, mid) + find_inversions(arr, mid+1, r); ans += merge_util(arr, l, r); return ans; } long long find_swaps(vector<int> from, vector<int> to) { assert(from.size() == to.size()); map<int, stack<int>> s; int n = from.size(); for(int ind = n-1; ind >= 0; ind--) s[to[ind]].push(ind); vector<int> pos; for(auto i:from) { pos.push_back(s[i].top()); s[i].pop(); } return find_inversions(pos, 0, n-1); } int64_t count_swaps(vector<int> s) { vector<int> to; for(auto i:s) { if(i < 0) { to.push_back(i); to.push_back(-i); } } return find_swaps(s, to); }

Compilation message (stderr)

shoes.cpp:41:9: error: ambiguating new declaration of 'int64_t count_swaps(std::vector<int>)'
   41 | int64_t count_swaps(vector<int> s) {
      |         ^~~~~~~~~~~
In file included from shoes.cpp:2:
shoes.h:7:11: note: old declaration 'long long int count_swaps(std::vector<int>)'
    7 | long long count_swaps(std::vector<int> S);
      |           ^~~~~~~~~~~