Submission #630668

#TimeUsernameProblemLanguageResultExecution timeMemory
630668fadyscubeArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int getIndex(vector<int> v, int K) {
    auto it = find(v.begin(), v.end(), K);
    if (it != v.end()) return it - v.begin();
    else return -1;
}

int ans = 0;
ll count_swaps(vector<int> S) {
    if (S.size() == 2) {
        ans += (S[0] > 0) ? 1 : 0;
        return ans;
    } else if (S.size() < 2) return ans;

    int in = getIndex(S, S[0]*-1);
    ans += S[0] > 0 ? in : in-1;
    S.erase(S.begin()+in);
    S.erase(S.begin()+0);
    return count_swaps(S, ans);
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:24:30: error: too many arguments to function 'long long int count_swaps(std::vector<int>)'
   24 |     return count_swaps(S, ans);
      |                              ^
shoes.cpp:14:4: note: declared here
   14 | ll count_swaps(vector<int> S) {
      |    ^~~~~~~~~~~