# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1079093 | boris_mihov | Selling RNA Strands (JOI16_selling_rna) | C++17 | 1572 ms | 8528 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <map>
typedef long long llong;
const int MAXN = 100000 + 10;
const int MOD1 = 1000003013;
const int MOD2 = 1000003241;
const int BASE = 5;
int n, q;
std::string s[MAXN];
void solve()
{
for (int i = 1 ; i <= q ; ++i)
{
std::string x, y;
std::cin >> x >> y;
std::reverse(y.begin(), y.end());
int cnt = 0;
for (int j = 1 ; j <= n ; ++j)
{
if (x.size() > s[j].size() || y.size() > s[j].size())
{
continue;
}
bool ok = true;
for (int k = 0 ; k < x.size() && ok ; ++k)
{
if (x[k] != s[j][k])
{
ok = false;
break;
}
}
std::reverse(s[j].begin(), s[j].end());
for (int k = 0 ; k < y.size() && ok ; ++k)
{
if (y[k] != s[j][k])
{
ok = false;
break;
}
}
std::reverse(s[j].begin(), s[j].end());
cnt += ok;
}
std::cout << cnt << '\n';
}
}
void input()
{
std::cin >> n >> q;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> s[i];
}
}
void fastIOI()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIOI();
input();
solve();
return 0;
}
Compilation message (stderr)
# | 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... |