Submission #1067793

# Submission time Handle Problem Language Result Execution time Memory
1067793 2024-08-21T03:21:35 Z ntnq Selling RNA Strands (JOI16_selling_rna) C++17
10 / 100
1500 ms 37716 KB
#include <bits/stdc++.h>
using namespace std;

string a[1000006], st1, st2;
int n, m;
long long ans;

bool check(string st, string s, string x)
{
    if (st.size()>x.size()) return false;
    if (s.size()>x.size()) return false;
    
    for (int i = 0; i<st.size(); i++)
        if (st[i]!=x[i]) return false;
    
    int i = s.size()-1;
    for (int j=x.size()-1; j>=0; j--)
    {
        if (s[i]!=x[j]) return false;
        i--;
        if (i==-1) return true;
    }
        
    return true;
    
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    for (int i=1; i<=n; i++) cin >> a[i];
    sort (a+1, a+n+1);
    
    for (int i=1; i<=m; i++)
    {
        cin >> st1 >> st2;
        
        ans = 0LL;
        for (int j=1; j<=n; j++)
        {
            if (a[j][1] != st1[0] && a[j][a[j].size()-1] != st2[st2.size()-1]) continue;
            if (check(st1, st2, a[j])) ans++;
        }
            
        
        cout << ans << '\n';
    }
}

Compilation message

selling_rna.cpp: In function 'bool check(std::string, std::string, std::string)':
selling_rna.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i<st.size(); i++)
      |                     ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 31580 KB Output is correct
2 Correct 15 ms 31580 KB Output is correct
3 Correct 14 ms 31580 KB Output is correct
4 Correct 15 ms 31640 KB Output is correct
5 Correct 14 ms 31576 KB Output is correct
6 Correct 15 ms 31576 KB Output is correct
7 Correct 14 ms 31580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 411 ms 33928 KB Output is correct
2 Correct 1014 ms 33912 KB Output is correct
3 Correct 1310 ms 37620 KB Output is correct
4 Execution timed out 1563 ms 37716 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1561 ms 31764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 31580 KB Output is correct
2 Correct 15 ms 31580 KB Output is correct
3 Correct 14 ms 31580 KB Output is correct
4 Correct 15 ms 31640 KB Output is correct
5 Correct 14 ms 31576 KB Output is correct
6 Correct 15 ms 31576 KB Output is correct
7 Correct 14 ms 31580 KB Output is correct
8 Correct 411 ms 33928 KB Output is correct
9 Correct 1014 ms 33912 KB Output is correct
10 Correct 1310 ms 37620 KB Output is correct
11 Execution timed out 1563 ms 37716 KB Time limit exceeded
12 Halted 0 ms 0 KB -