Submission #92822

# Submission time Handle Problem Language Result Execution time Memory
92822 2019-01-05T08:36:29 Z LittleFlowers__ Selling RNA Strands (JOI16_selling_rna) C++14
0 / 100
1500 ms 1904 KB
#include <bits/stdc++.h>
using namespace std;
const int N=100;
int n,m,G,Il,Ir;
int Tl[N][4],Tr[N][4];
vector<int> Fl[N],Fr[N];
string s;
void add(int i)
{
    cin>>s;
    for(auto & c : s)
    {
        if(c=='G') c='B';
        if(c=='U') c='D';
    }
    G=0;
    for(auto & c : s)
    {
        if(!Tl[G][c-'A']) Tl[G][c-'A']=++Il;
        G=Tl[G][c-'A'];
        Fl[G].push_back(i);
    }
    reverse(s.begin(),s.end());
    G=0;
    for(auto & c : s)
    {
        if(!Tr[G][c-'A']) Tr[G][c-'A']=++Ir;
        G=Tr[G][c-'A'];
        Fr[G].push_back(i);
    }
}
void get()
{
    vector<int> A;
    G=0;
    cin>>s;
    for(auto & c : s)
    {
        if(c=='G') c='B';
        if(c=='U') c='D';
    }
    for(auto & c : s)
    {
        G=Tl[G][c-'A'];
        if(!G) break;
    }
    A.insert(A.end(),Fl[G].begin(),Fl[G].end());
    G=0;
    cin>>s;
    for(auto & c : s)
    {
        if(c=='G') c='B';
        if(c=='U') c='D';
    }
    reverse(s.begin(),s.end());
    for(auto & c : s)
    {
        G=Tr[G][c-'A'];
        if(!G) break;
    }
    A.insert(A.end(),Fr[G].begin(),Fr[G].end());
    sort(A.begin(),A.end());
    int ans=0;
    for(int i=0; i<(int)A.size()-1; ++i) ans+=A[i]==A[i+1];
    cout<<ans<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("RNA.inp","r",stdin);
    cin>>n>>m;
    for(int i=0; i<n; ++i) add(i);
    for(int i=0; i<m; ++i) get();
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1569 ms 1904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -