# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245706 | yasseenkamel | Selling RNA Strands (JOI16_selling_rna) | C++14 | 1591 ms | 6260 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
const long double EPS=1e-9;
const int MOD=1e9+7;
const int N=1e6;
int n,m;
vector<string> s;
in main(){
cin >> n >> m;
string x;
for(int i = 0 ; i < n ; i ++){
cin >> x;
s.push_back(x);
}
while(m --){
string s1,s2;
cin >> s1 >> s2;
int ans = 0;
for(int i = 0 ; i < n ; i ++){
bool b = 1;
for(int j = 0 ; j < s1.size() && j < s[i].size() ; j ++){
if(s[i][j] != s1[j]){
b = 0;
break;
}
}
if(!b){
continue;
}
int idx = s2.size() - 1;
for(int j = s[i].size() - 1 ; j >= 0 && idx >= 0 ; j --){
if(s[i][j] != s2[idx]){
b = 0;
break;
}
idx --;
}
ans += b;
}
cout << ans << endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |