// clang-format off
#include <bits/stdc++.h>
using i64 = int64_t;
namespace space {
template <typename T> bool setmax(T &v, const T a) {
if (v < a) {
v = a;
return true;
} else {
return false;
}
}
int N, M;
std::vector<int> S, X, Y, P, Q;
std::vector<int> RS;
void swap(const int a, const int b) {
P.push_back(a);
Q.push_back(b);
std::swap(S[a], S[b]);
std::swap(RS[S[a]], RS[S[b]]);
}
int solve() {
for (int i = 0; i < N; ++i) {
const int pos_i = RS[i];
if (pos_i != i) swap(i, pos_i);
}
return (int)P.size();
}
int mfindSwapSpace(int n, int s[], int m, int x[], int y[], int rp[], int rq[]) {
N = n;
M = m;
S.resize(N);
X.resize(N);
Y.resize(N);
RS.resize(N);
for (int i = 0; i < N; ++i) {
S[i] = s[i];
RS[S[i]] = i;
}
for (int i = 0; i < M; ++i) {
X[i] = x[i];
Y[i] = y[i];
}
const int R = solve();
for (int i = 0; i < R; ++i) {
rp[i] = P[i];
rq[i] = Q[i];
}
return R;
}
}
int findSwapSpace(int n, int s[], int m, int x[], int y[], int rp[], int rq[]) {
return space::mfindSwapSpace(n, s, m, x, y, rp, rq);
}
Compilation message
/usr/bin/ld: /tmp/ccKFancE.o: in function `main':
grader.c:(.text.startup+0x4eb): undefined reference to `findSwapPairs(int, int*, int, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status