Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <random>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <list>

#define DBG
#ifdef DBG
#define PRINT_TIME(s,e) cout << (double)(e-s) << " CLOCK" << endl
#define LOOP for ( int i=0; i<MAXIMUM; i++ )
#define START start = clock();
#define END end = clock(); PRINT_TIME(start,end);
#else
#define PRINT_TIME(s,e)
#define LOOP
#define START
#define END
#endif


using namespace std;

int comp ( const char x, const char y, const array<char,26> dict ){
    int xp = -1;
    int yp = -1;
    for( int i=0; i<26; i++ ){
        if( x == dict[i] ){
            xp = i;
            break;
        }
    }
    for( int i=0; i<26; i++ ){
        if( y == dict[i] ){
            yp = i;
            break;
        }
    }
    return xp - yp;
}

unsigned long compstr( const string x, const string y, const array<char,26> dict ) {
    for (int i = 0; i < min(x.length(), y.length()); i++) {
        if (x[i] == y[i])
            continue;
        return comp(x[i], y[i],dict);
    }
    return x.length() + y.length() - y.length();
}

int main(void) {

#ifdef DBG
    static clock_t start,end;
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    int N;
    cin >> N;
    string S[N];
    for( int i=0; i<N; i++ ){
        cin >> S[i];
    }
    long Q;
    cin >> Q;
    array<char,26> q;
    for( int aa=0; aa<Q; aa++ ){
        int t[N];
        for( int i=0; i<N; i++ ){
            t[i] = i;
        }
        long k;
        string ql;
        cin >> k >> ql;
        for(int i=0; i<26; i++){
            q[i] = ql[i];
        }
        int temp;
        for (int i = 0; i < N - 1; i++) {
            for (int j = N - 1; j > i; j--) {
                if (compstr(S[t[i]],S[t[j]], q) > 0) {  /* 前の要素の方が大きかったら */
                    temp = t[j];        /* 交換する */
                    t[j] = t[j - 1];
                    t[j - 1]= temp;
                }
            }
        }
        cout << t[k]+1
             << endl;
    }
}

//inline int is

Compiler output:
a.cc:26:61: error: 'dict' has incomplete type
   26 | int comp ( const char x, const char y, const array<char,26> dict ){
      |                                        ~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: declaration of 'struct std::array<char, 26>'
   99 |     struct array;
      |            ^~~~~
a.cc:44:77: error: 'dict' has incomplete type
   44 | unsigned long compstr( const string x, const string y, const array<char,26> dict ) {
      |                                                        ~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: declaration of 'struct std::array<char, 26>'
   99 |     struct array;
      |            ^~~~~
a.cc: In function 'int main()':
a.cc:69:20: error: aggregate 'std::array<char, 26> q' has incomplete type and cannot be defined
   69 |     array<char,26> q;
      |                    ^
a.cc:9:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
    8 | #include <list>
  +++ |+#include <array>
    9 |