#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
#define out(x) "{" << (#x) << ": " << x << "} "
const int MAX_N = 1e6 + 01;
string in[MAX_N];
bool eval(int ind, string st, string en) {
for(int i = 0; i < st.size(); i ++) {
if(in[ind][i] != st[i]) {
return false;
}
}
for(int i = 0; i < en.size(); i ++) {
if(in[ind][in[ind].size() - en.size() + i] != en[i]) {
return false;
}
}
return true;
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i ++) {
cin >> in[i];
}
for(int i = 0; i < m; i ++) {
string st, en;
cin >> st >> en;
int cnt = 0;
for(int j = 0; j < n; j ++) {
cnt += eval(j, st, en);
}
cout << cnt << endl;
}
return 0;
}
Compilation message
selling_rna.cpp: In function 'bool eval(int, std::string, std::string)':
selling_rna.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int i = 0; i < st.size(); i ++) {
| ~~^~~~~~~~~~~
selling_rna.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 0; i < en.size(); i ++) {
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
31596 KB |
Output is correct |
2 |
Correct |
21 ms |
31596 KB |
Output is correct |
3 |
Correct |
21 ms |
31596 KB |
Output is correct |
4 |
Correct |
21 ms |
31596 KB |
Output is correct |
5 |
Correct |
22 ms |
31596 KB |
Output is correct |
6 |
Correct |
21 ms |
31596 KB |
Output is correct |
7 |
Correct |
21 ms |
31596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1521 ms |
37796 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1534 ms |
31724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
31596 KB |
Output is correct |
2 |
Correct |
21 ms |
31596 KB |
Output is correct |
3 |
Correct |
21 ms |
31596 KB |
Output is correct |
4 |
Correct |
21 ms |
31596 KB |
Output is correct |
5 |
Correct |
22 ms |
31596 KB |
Output is correct |
6 |
Correct |
21 ms |
31596 KB |
Output is correct |
7 |
Correct |
21 ms |
31596 KB |
Output is correct |
8 |
Execution timed out |
1521 ms |
37796 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |