Submission #1088459

#TimeUsernameProblemLanguageResultExecution timeMemory
1088459LucasLeArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; int n; int fen[maxn + 5]; void update(int v, int x) { for (; v <= 2 * n; v += v & (-v)) { fen[v] += x; } } int get(int v) { int ans = 0; for (; v; v -= v & (-v)) ans += fen[v]; return ans; } int count_swaps(vector<int> s) { n = (int)s.size() / 2; vector<int> L[n + 1], R[n + 1]; for (int i = 0; i < (int)s.size(); ++i) { if (s[i] < 0) L[-s[i]].push_back(i + 1); else R[s[i]].push_back(i + 1); } int res = 0; vector<pair<int, int>> vec; for (int i = 1; i <= n; ++i) { for (int j = 0; j < (int)L[i].size(); ++j) { int p1 = L[i][j], p2 = R[i][j]; if (p1 > p2) { res++; swap(p1, p2); } vec.push_back({p1, p2}); } } sort(vec.begin(), vec.end()); for (int i = 0; i < (int)vec.size(); ++i) { int s1 = get(vec[i].first); int s2 = get(vec[i].second); res += s2 - s1 + (i - s2) * 2; update(vec[i].second, 1); } return res; }

Compilation message (stderr)

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