#include <bits/stdc++.h>
using namespace std;
/*
<<<<It's never too late for a new beginning in your life>>>>
Today is hard
tomorrow will worse
but the day after tomorrow will be the sunshine..
HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............
Never give up */
//The most CHALISHKANCHIK
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//~ #define int long long
void solve(){
map<pair<string, string> , int> mp;
int n, m;
cin >> n >> m;
if(n*m <= 90000000){
vector<string> v;
for(int i = 0; i < n; i++){
string s;
cin >> s;
v.pb(s);
}
for(int i = 0; i < m; i++){
string a, b;
cin >> a >> b;
int ans = 0;
for(int j = 0; j < n; j++){
if(v[j].size() < a.size() || v[j].size() < b.size())continue;
if(v[j].substr(0, a.size()) == a && v[j].substr(v[j].size()-b.size()) == b)ans++;
}
cout << ans << '\n';
}
return;
}
for(int i = 0; i < n; i++){
string s;
cin >> s;
for(int k = 0; k < (int)s.size(); k++){
for(int j = 0; j < (int)s.size(); j++){
string s1 = s.substr(0, k+1), s2 = s.substr(j);
mp[{s1, s2}]++;
}
}
}
for(int i = 0; i < m; i++){
string a, b;
cin >> a >> b;
cout << mp[{a,b}] << '\n';
}
}
main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int t = 1;
//~ cin >> t;
while(t--){
solve();
}
}
Compilation message
selling_rna.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
58 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
2396 KB |
Output is correct |
2 |
Correct |
557 ms |
2700 KB |
Output is correct |
3 |
Correct |
172 ms |
2620 KB |
Output is correct |
4 |
Correct |
248 ms |
2716 KB |
Output is correct |
5 |
Correct |
457 ms |
1952 KB |
Output is correct |
6 |
Correct |
464 ms |
1964 KB |
Output is correct |
7 |
Correct |
406 ms |
1880 KB |
Output is correct |
8 |
Correct |
934 ms |
2668 KB |
Output is correct |
9 |
Correct |
815 ms |
2668 KB |
Output is correct |
10 |
Correct |
1417 ms |
2668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1568 ms |
2520 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
132 ms |
2396 KB |
Output is correct |
9 |
Correct |
557 ms |
2700 KB |
Output is correct |
10 |
Correct |
172 ms |
2620 KB |
Output is correct |
11 |
Correct |
248 ms |
2716 KB |
Output is correct |
12 |
Correct |
457 ms |
1952 KB |
Output is correct |
13 |
Correct |
464 ms |
1964 KB |
Output is correct |
14 |
Correct |
406 ms |
1880 KB |
Output is correct |
15 |
Correct |
934 ms |
2668 KB |
Output is correct |
16 |
Correct |
815 ms |
2668 KB |
Output is correct |
17 |
Correct |
1417 ms |
2668 KB |
Output is correct |
18 |
Execution timed out |
1568 ms |
2520 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |