Language: C++

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;


class Radix {
private:
    const char* s;
    int a[128];
public:
    Radix(const char* s = "0123456789ABCDEF") : s(s) {
        int i;
        for (i = 0; s[i]; ++i)
            a[(int)s[i]] = i;
    }
    std::string to(long long p, int q) {
        int i;
        if (!p)
            return "0";
        char t[64] = { };
        for (i = 62; p; --i) {
            t[i] = s[p % q];
            p /= q;
        }
        return std::string(t + i + 1);
    }
    std::string to(const std::string& t, int p, int q) {
        return to(to(t, p), q);
    }
    long long to(const std::string& t, int p) {
        int i;
        long long sm = a[(int)t[0]];
        for (i = 1; i < (int)t.length(); ++i)
            sm = sm * p + a[(int)t[i]];
        return sm;
    }
};

bool vector_has(vector<int> vec, int num) {
    auto itr = std::find(vec.begin(), vec.end(), num);
    size_t index = std::distance(vec.begin(), itr);
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

int main() {
    Radix r;
    int N, temp;
    string T;
    int T_length;
    cin >> temp;
    N = (int)pow(3, temp);
    cin >> T;
    T_length = (int)T.length();
    int* list = new int[N];
    string temp_str;

    // initialize
    for (int i = 0; i < N; i++) {
        list[i] = i;
    }

    // operation
    for (int i = 0; i < T_length; i++) {
        // salsa
        if (T[i] == 'S') {
            vector<vector<int>> swap_index(N, vector<int>(N));
            for (int list_index = 0; list_index < N; list_index++)
            {
                    // convert list_index from decimal to ternary
                    temp_str = r.to(list_index, 3);
                    int temp_str_length = (int)temp_str.length();
                    // swap 1 with 2
                    for (int j = 0; j < temp_str_length; j++) {
                        switch (temp_str[j]) {
                        case '1':
                            temp_str[j] = '2';
                            break;
                        case '2':
                            temp_str[j] = '1';
                            break;
                        }
                    }
                    // convert ternary to decimal
                    temp = r.to(temp_str, 3);

                    // check if swap hasn't been done for temp and list_index
                    if (!vector_has(swap_index[list_index], temp)) {
                        // convert string to integer
                        swap(list[list_index], list[temp]);
                        // register swapped opponent
                        swap_index[list_index].push_back(temp);
                        swap_index[temp].push_back(list_index);
                    }

            }
        }
        // rumba
        else
        {
            for (int j = N - 1; 0 < j; j--) {
                swap(list[j - 1], list[j]);
            }
        }
    }
    int* list_pos = new int[N];
    for (int i = 0; i < N; i++) {
        list_pos[list[i]] = i;
    }

    for (int i = 0; i < N; i++) {
        cout << list_pos[i] << " ";
    }
    cout << endl;

    return 0;
}

Compiler output:
a.cc: In function 'bool vector_has(std::vector<int>, int)':
a.cc:43:25: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   43 |     auto itr = std::find(vec.begin(), vec.end(), num);
      |                ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:43:25: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   43 |     auto itr = std::find(vec.begin(), vec.end(), num);
      |                ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~