답안 #1079093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079093 2024-08-28T10:39:37 Z boris_mihov Selling RNA Strands (JOI16_selling_rna) C++17
10 / 100
1500 ms 8528 KB
#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

selling_rna.cpp: In function 'void solve()':
selling_rna.cpp:35:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for (int k = 0 ; k < x.size() && ok ; ++k)
      |                              ~~^~~~~~~~~~
selling_rna.cpp:45:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             for (int k = 0 ; k < y.size() && ok ; ++k)
      |                              ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 2 ms 3592 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 2 ms 3580 KB Output is correct
5 Correct 2 ms 3420 KB Output is correct
6 Correct 2 ms 3456 KB Output is correct
7 Correct 1 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1511 ms 8528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1572 ms 3932 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 2 ms 3592 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 2 ms 3580 KB Output is correct
5 Correct 2 ms 3420 KB Output is correct
6 Correct 2 ms 3456 KB Output is correct
7 Correct 1 ms 3416 KB Output is correct
8 Execution timed out 1511 ms 8528 KB Time limit exceeded
9 Halted 0 ms 0 KB -