Submission #630663

#TimeUsernameProblemLanguageResultExecution timeMemory
630663fadyscubeArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <vector> 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; } ll count_swaps(vector<int> S, ll ans = 0) { 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); } int main () { ll n; cin >> n; vector<int> v(n*2); for (int i = 0; i < n*2; i++) cin >> v[i]; cout << count_swaps(v) << endl; return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccaYUABw.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccFnNUkt.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccaYUABw.o: in function `main':
grader.cpp:(.text.startup+0x2a8): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status