# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332623 | 2020-12-03T01:39:14 Z | daniel920712 | Selling RNA Strands (JOI16_selling_rna) | C++14 | 1500 ms | 48492 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <vector> #include <algorithm> #include <string.h> using namespace std; long long MOD=1e9+7; vector < long long > a[100005],b[100005]; char tt[100005]; char tt2[100005]; long long sz[100005]; int main() { long long N,M,K,t=0,i,j,t2,xx,yy,ans; scanf("%lld %lld",&N,&M); for(i=0;i<N;i++) { scanf("%s",tt); K=(long long) strlen(tt); sz[i]=K; t=0; for(j=0;j<K;j++) { t*=4; if(tt[j]=='U') t++; if(tt[j]=='C') t+=2; if(tt[j]=='G') t+=3; t%=MOD; //printf("%lld ",t); a[i].push_back(t); } //printf("\n"); t=0; for(j=K-1;j>=0;j--) { t*=4; if(tt[j]=='U') t++; if(tt[j]=='C') t+=2; if(tt[j]=='G') t+=3; t%=MOD; //printf("%lld ",t); b[i].push_back(t); } //printf("\n\n"); } while(M--) { ans=0; scanf("%s %s",tt,tt2); xx=strlen(tt); yy=strlen(tt2); t=0; for(j=0;j<xx;j++) { t*=4; if(tt[j]=='U') t++; if(tt[j]=='C') t+=2; if(tt[j]=='G') t+=3; t%=MOD; } t2=0; for(j=yy-1;j>=0;j--) { t2*=4; if(tt2[j]=='U') t2++; if(tt2[j]=='C') t2+=2; if(tt2[j]=='G') t2+=3; t2%=MOD; } //printf("%lld %lld\n",t,t2); for(i=0;i<N;i++) { if(sz[i]<xx||sz[i]<yy) continue; if(a[i][xx-1]==t&&b[i][yy-1]==t2) ans++; } printf("%lld\n",ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4972 KB | Output is correct |
2 | Correct | 5 ms | 4972 KB | Output is correct |
3 | Correct | 4 ms | 4972 KB | Output is correct |
4 | Correct | 4 ms | 5100 KB | Output is correct |
5 | Correct | 4 ms | 4972 KB | Output is correct |
6 | Correct | 4 ms | 4972 KB | Output is correct |
7 | Correct | 4 ms | 4972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 137 ms | 44396 KB | Output is correct |
2 | Correct | 386 ms | 48364 KB | Output is correct |
3 | Correct | 237 ms | 46316 KB | Output is correct |
4 | Correct | 297 ms | 48492 KB | Output is correct |
5 | Correct | 303 ms | 31468 KB | Output is correct |
6 | Correct | 321 ms | 31852 KB | Output is correct |
7 | Correct | 236 ms | 36716 KB | Output is correct |
8 | Correct | 399 ms | 45292 KB | Output is correct |
9 | Correct | 350 ms | 45292 KB | Output is correct |
10 | Correct | 667 ms | 45608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1548 ms | 8816 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4972 KB | Output is correct |
2 | Correct | 5 ms | 4972 KB | Output is correct |
3 | Correct | 4 ms | 4972 KB | Output is correct |
4 | Correct | 4 ms | 5100 KB | Output is correct |
5 | Correct | 4 ms | 4972 KB | Output is correct |
6 | Correct | 4 ms | 4972 KB | Output is correct |
7 | Correct | 4 ms | 4972 KB | Output is correct |
8 | Correct | 137 ms | 44396 KB | Output is correct |
9 | Correct | 386 ms | 48364 KB | Output is correct |
10 | Correct | 237 ms | 46316 KB | Output is correct |
11 | Correct | 297 ms | 48492 KB | Output is correct |
12 | Correct | 303 ms | 31468 KB | Output is correct |
13 | Correct | 321 ms | 31852 KB | Output is correct |
14 | Correct | 236 ms | 36716 KB | Output is correct |
15 | Correct | 399 ms | 45292 KB | Output is correct |
16 | Correct | 350 ms | 45292 KB | Output is correct |
17 | Correct | 667 ms | 45608 KB | Output is correct |
18 | Execution timed out | 1548 ms | 8816 KB | Time limit exceeded |
19 | Halted | 0 ms | 0 KB | - |