답안 #92823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92823 2019-01-05T08:37:15 Z LittleFlowers__ Selling RNA Strands (JOI16_selling_rna) C++14
10 / 100
1500 ms 425720 KB
#include <bits/stdc++.h>
using namespace std;
const int N=2000010;
int n,m,G,Il,Ir;
int Tl[N][26],Tr[N][26];
vector<int> Fl[N],Fr[N];
string s;
void add(int i)
{
    cin>>s;
    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)
    {
        G=Tl[G][c-'A'];
        if(!G) break;
    }
    A.insert(A.end(),Fl[G].begin(),Fl[G].end());
    G=0;
    cin>>s;
    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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 94328 KB Output is correct
2 Correct 86 ms 94360 KB Output is correct
3 Correct 77 ms 94404 KB Output is correct
4 Correct 73 ms 94332 KB Output is correct
5 Correct 77 ms 94304 KB Output is correct
6 Correct 73 ms 94328 KB Output is correct
7 Correct 75 ms 94300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 539 ms 371704 KB Output is correct
2 Correct 861 ms 356948 KB Output is correct
3 Correct 850 ms 367680 KB Output is correct
4 Correct 960 ms 354680 KB Output is correct
5 Correct 651 ms 420732 KB Output is correct
6 Correct 644 ms 425720 KB Output is correct
7 Correct 696 ms 116856 KB Output is correct
8 Correct 672 ms 301900 KB Output is correct
9 Correct 568 ms 270308 KB Output is correct
10 Execution timed out 1584 ms 263180 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1572 ms 96088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 94328 KB Output is correct
2 Correct 86 ms 94360 KB Output is correct
3 Correct 77 ms 94404 KB Output is correct
4 Correct 73 ms 94332 KB Output is correct
5 Correct 77 ms 94304 KB Output is correct
6 Correct 73 ms 94328 KB Output is correct
7 Correct 75 ms 94300 KB Output is correct
8 Correct 539 ms 371704 KB Output is correct
9 Correct 861 ms 356948 KB Output is correct
10 Correct 850 ms 367680 KB Output is correct
11 Correct 960 ms 354680 KB Output is correct
12 Correct 651 ms 420732 KB Output is correct
13 Correct 644 ms 425720 KB Output is correct
14 Correct 696 ms 116856 KB Output is correct
15 Correct 672 ms 301900 KB Output is correct
16 Correct 568 ms 270308 KB Output is correct
17 Execution timed out 1584 ms 263180 KB Time limit exceeded