# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
92829 | 2019-01-05T08:51:53 Z | LittleFlowers__ | Selling RNA Strands (JOI16_selling_rna) | C++14 | 1500 ms | 256 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1563 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1576 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1562 ms | 252 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1563 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |