Submission #866764

# Submission time Handle Problem Language Result Execution time Memory
866764 2023-10-27T03:15:03 Z vjudge1 Selling RNA Strands (JOI16_selling_rna) C++17
0 / 100
437 ms 21588 KB
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
map<string, int> tt, ht;
int n, q, mt, mh;
string s[N], a[N], b[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; i++) cin>>s[i];
    for(int i=1; i<=q; i++)
    {
        cin>>a[i]>>b[i];
        int v=a[i].size(), u=b[i].size();
        mt=max(mt, v);
        mh=max(mh, u);
    }
    for(int i=1; i<=n; i++)
    {
        int v=s[i].size();
        string re="";
        for(int j=0; j<min(v, mt); j++)
        {
            re+=s[i][j];
            tt[re]++;
        }
    }
    for(int i=1; i<=n; i++)
    {
        int v=s[i].size();
        string re="";
        for(int j=v-1; j>=v-min(v,mh); j--)
        {
            re=s[i][j]+re;
            ht[re]++;
        }
    }
    for(int i=1; i<=q; i++)
    {
        cout<<min(tt[a[i]], ht[b[i]])<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 437 ms 21588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 10076 KB Output is correct
2 Incorrect 21 ms 9884 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9816 KB Output isn't correct
2 Halted 0 ms 0 KB -