이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 100'000 + 10;
int n, m;
string str[N];
pair<string, string> Q[N];
 
int convert(const auto& a) { return a == 'A' ? 0 : a == 'C' ? 1 : a == 'G' ? 2 : 3; }
int nwt[N << 2][4];
int answer[N];
struct Trie {
  int it;
  vector<array<int, 4>> nwt;
  vector<int> id;
 
  void add(string s, int idx) {
    int g = 0;
    for (int i = 1; i <= (int)s.size(); ++i) {
      while (nwt.size() <= g) nwt.push_back(array<int, 4>());
 
      int path = convert(s[i - 1]);
      if (!nwt[g][path]) nwt[g][path] = ++it;
      g = nwt[g][path];
 
      while (id.size() <= it) id.push_back(false);
    }
    id[g] = idx;
  }
 
  void get(string s) { 
    int ret = 0;
    int g = 0;
    for (int i = 1; i <= (int)s.size(); ++i) {
      int path = convert(s[i - 1]);
      if (nwt.size() <= g || !nwt[g][path]) return;
      g = nwt[g][path];
      answer[id[g]] += 1;
    }
  }
} T[N << 2];
 
int it;
void add(const auto& s, const auto& e, int idx) { 
  int g = 0;
  for (int i = 1; i <= (int)s.size(); ++i) { 
    int path = convert(s[i - 1]);
    if (!nwt[g][path]) nwt[g][path] = ++it;
    g = nwt[g][path];
  }
  T[g].add(string(e.rbegin(), e.rend()), idx);
}
 
void get(const auto& s) { 
  string rs = string(s.rbegin(), s.rend());
  int g = 0;
  for (int i = 1; i <= (int)s.size(); ++i) { 
    int path = convert(s[i - 1]);
    if (!nwt[g][path]) return;
    g = nwt[g][path];
    T[g].get(rs);
  }
}
int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);
 
  cin >> n >> m;
 
  for (int i = 1; i <= n; ++i) cin >> str[i];
  for (int i = 1; i <= m; ++i) { 
    string s, e; cin >> s >> e;
    Q[i] = {s, e};
  }
  vector<pair<string, string>> que(Q + 1, Q + m + 1);
  sort(que.begin(), que.end());
  que.resize(unique(que.begin(), que.end()) - que.begin());
  {
    int it = 0;
    for (const auto& [s, e] : que) add(s, e, ++it);
    for (int i = 1; i <= n; ++i) get(str[i]);
  }
  for (int i = 1; i <= m; ++i) { 
    int idx = lower_bound(que.begin(), que.end(), Q[i]) - que.begin() + 1;
    cout << answer[idx] << "\n";
  }
}
컴파일 시 표준 에러 (stderr) 메시지
selling_rna.cpp:12:19: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   12 | int convert(const auto& a) { return a == 'A' ? 0 : a == 'C' ? 1 : a == 'G' ? 2 : 3; }
      |                   ^~~~
selling_rna.cpp: In member function 'void Trie::add(std::string, int)':
selling_rna.cpp:24:25: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<int, 4> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |       while (nwt.size() <= g) nwt.push_back(array<int, 4>());
      |              ~~~~~~~~~~~^~~~
selling_rna.cpp:30:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |       while (id.size() <= it) id.push_back(false);
      |              ~~~~~~~~~~^~~~~
selling_rna.cpp: In member function 'void Trie::get(std::string)':
selling_rna.cpp:40:22: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<int, 4> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |       if (nwt.size() <= g || !nwt[g][path]) return;
      |           ~~~~~~~~~~~^~~~
selling_rna.cpp:36:9: warning: unused variable 'ret' [-Wunused-variable]
   36 |     int ret = 0;
      |         ^~~
selling_rna.cpp: At global scope:
selling_rna.cpp:48:16: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   48 | void add(const auto& s, const auto& e, int idx) {
      |                ^~~~
selling_rna.cpp:48:31: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   48 | void add(const auto& s, const auto& e, int idx) {
      |                               ^~~~
selling_rna.cpp:58:16: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   58 | void get(const auto& s) {
      |                ^~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |