# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101155 | 2019-03-17T06:52:28 Z | autumn_eel | Selling RNA Strands (JOI16_selling_rna) | C++14 | 1500 ms | 69648 KB |
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) #define MOD 1000000007 using namespace std; typedef long long ll; typedef pair<int,int>P; struct rolling_hash{ ll B=10007; vector<ll>mul,hsh; rolling_hash(){} rolling_hash(string&s){ mul=hsh=vector<ll>(s.size()+1); mul[0]=1; for(int i=1;i<=s.size();i++){ mul[i]=(mul[i-1]*B)%MOD; hsh[i]=(hsh[i-1]*B+s[i-1])%MOD; } } ll get(int l,int r){//[l,r) return (hsh[r]+MOD-hsh[l]*mul[r-l]%MOD)%MOD; } }; char S[200000]; string s[200000],p[200000],q[200000]; rolling_hash rh[200000]; int main(){ int n,m;scanf("%d%d",&n,&m); if(n>5000||m>5000)abort(); rep(i,n){ scanf("%s",S); s[i]=S; rh[i]=rolling_hash(s[i]); } rep(i,m){ scanf("%s",S);p[i]=S; scanf("%s",S);q[i]=S; rolling_hash a(p[i]),b(q[i]); int cnt=0; rep(j,n){ if(p[i].size()>s[j].size()||q[i].size()>s[j].size())continue; if(rh[j].get(0,p[i].size())==a.get(0,p[i].size())&& rh[j].get(s[j].size()-q[i].size(),s[j].size())==b.get(0,q[i].size()))cnt++; } printf("%d\n",cnt); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 30072 KB | Output is correct |
2 | Correct | 32 ms | 30080 KB | Output is correct |
3 | Correct | 35 ms | 30080 KB | Output is correct |
4 | Correct | 32 ms | 30072 KB | Output is correct |
5 | Correct | 29 ms | 30080 KB | Output is correct |
6 | Correct | 29 ms | 30072 KB | Output is correct |
7 | Correct | 31 ms | 30080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 385 ms | 69380 KB | Output is correct |
2 | Execution timed out | 1551 ms | 69648 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 67 ms | 60024 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 | Correct | 37 ms | 30072 KB | Output is correct |
2 | Correct | 32 ms | 30080 KB | Output is correct |
3 | Correct | 35 ms | 30080 KB | Output is correct |
4 | Correct | 32 ms | 30072 KB | Output is correct |
5 | Correct | 29 ms | 30080 KB | Output is correct |
6 | Correct | 29 ms | 30072 KB | Output is correct |
7 | Correct | 31 ms | 30080 KB | Output is correct |
8 | Correct | 385 ms | 69380 KB | Output is correct |
9 | Execution timed out | 1551 ms | 69648 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |