답안 #92830

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92830 2019-01-05T08:52:34 Z LittleFlowers__ Selling RNA Strands (JOI16_selling_rna) C++14
0 / 100
6 ms 2416 KB
#include <bits/stdc++.h>
using namespace std;
const int SIZE=1<<10;
int pointer = SIZE;
char buffer[SIZE];
inline char gch(){if(pointer==SIZE){fread(buffer,1,SIZE,stdin);pointer=0;}return buffer[pointer++];}
inline int in(){int x=0;char c=gch();bool neg=false;while(c!='-'&&('0'>c||c>'9')) c=gch();if(c=='-') neg=true,c=gch();while('0'<=c&&c<='9') x=10*x+c-'0',c=gch();if(neg) x=-x;return x;}
inline string sn()
{
    string s="";char c;
    while(!isupper(c=gch()));
    while(isupper(c)) s+=c,c=gch();
    return s;}
inline void out(int x){if(x>9) out(x/10);putchar(x%10+'0');}
const int N=110;
int n,m,G,Il,Ir;
int Tl[N][4],Tr[N][4];
int C[N];
vector<int> Fl[N],Fr[N];
string s;

void add(int i)
{
    s=sn();
    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()
{
    G=0;
    s=sn();
    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;
    }
    int GG=G;
    for(auto & i : Fl[G]) C[i]++;
    G=0;
    s=sn();
    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;
    }
    int ans=0;
    for(auto & i : Fr[G]) ans+=C[i];
    for(auto & i : Fl[GG]) C[i]=0;
    //cout<<ans<<"\n";
    out(ans),putchar('\n');
}
int main()
{
    //freopen("RNA.inp","r",stdin);
    n=in(),m=in();
    for(int i=0; i<n; ++i) add(i);
    for(int i=0; i<m; ++i) get();
}

Compilation message

selling_rna.cpp: In function 'char gch()':
selling_rna.cpp:6:42: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 inline char gch(){if(pointer==SIZE){fread(buffer,1,SIZE,stdin);pointer=0;}return buffer[pointer++];}
                                     ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 2416 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -